fusion_core/security/
error.rs1use serde::Serialize;
2use thiserror::Error;
3
4pub type Result<T> = core::result::Result<T, Error>;
5
6#[derive(Debug, Error)]
7pub enum Error {
8 #[error("Hmac failure new from slice")]
9 HmacFailNewFromSlice,
10
11 #[error("Invalid format")]
12 InvalidFormat,
13
14 #[error("Cannot decode ident")]
15 CannotDecodeIdent,
16
17 #[error("Cannot decode exp")]
18 CannotDecodeExp,
19
20 #[error("Signature not matching")]
21 SignatureNotMatching,
22
23 #[error("Exp not iso")]
24 ExpNotIso,
25
26 #[error("Token expired")]
27 TokenExpired,
28
29 #[error("Failed to hash password")]
30 FailedToHashPassword,
31
32 #[error("Invalid password")]
33 InvalidPassword,
34
35 #[error("Failed to verify password")]
36 FailedToVerifyPassword,
37
38 #[error(transparent)]
39 JoseError(#[from] josekit::JoseError),
40}
41
42impl Serialize for Error {
43 fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
44 where
45 S: serde::Serializer,
46 {
47 serializer.serialize_str(&self.to_string())
48 }
49}