wallet_standard_base/
errors.rs

1use std::borrow::Cow;
2
3pub type WalletBaseResult<'wa, T> = Result<T, WalletBaseError<'wa>>;
4
5#[derive(Debug, PartialEq, Eq, Clone, thiserror::Error)]
6pub enum WalletBaseError<'wa> {
7    #[error("Invalid Base58 string: `{0}`")]
8    InvalidBase58Address(Cow<'wa, str>),
9    #[error(
10        "The public key length is expected to be 32 bytes but encountered public key of a length `{0}` bytes"
11    )]
12    InvalidEd25519PublicKeyLen(u8),
13    #[error(
14        "Sign In nonce is required to be at least 8 characters long but given nonce is `{0}` characters long!"
15    )]
16    NonceMustBeAtLeast8Characters(u8),
17    #[error("Adding one system time to the other caused overflow")]
18    SystemTimeCheckedAddOverflow,
19    #[error(
20        "The issued time should be earlier than the expiry time; Issued at: `{issued}`, Expires at: `{expiry}`"
21    )]
22    ExpiryTimeEarlierThanIssuedTime {
23        issued: Cow<'wa, str>,
24        expiry: Cow<'wa, str>,
25    },
26    #[error(
27        "The expiry time should be later than the current time; Expires at: `{expiry}`, Current tine at: `{now}`"
28    )]
29    ExpirationTimeIsInThePast {
30        now: Cow<'wa, str>,
31        expiry: Cow<'wa, str>,
32    },
33    #[error(
34        "The not before time be later than the issued time; Issued at: `{issued_at}`, Not Before Time at: `{not_before}`"
35    )]
36    NotBeforeTimeEarlierThanIssuedTime {
37        issued_at: Cow<'wa, str>,
38        not_before: Cow<'wa, str>,
39    },
40    #[error(
41        "The not before set is earlier than current time; Current time at: `{now}`, Not Before Time at: `{not_before}`"
42    )]
43    NotBeforeTimeIsInThePast {
44        now: Cow<'wa, str>,
45        not_before: Cow<'wa, str>,
46    },
47    #[error(
48        "The expiration time is earlier that not before time. A token cannot expire before it's valid; Expiry time at: `{expiry}`, Not Before Time at: `{not_before}`"
49    )]
50    NotBeforeTimeLaterThanExpirationTime {
51        not_before: Cow<'wa, str>,
52        expiry: Cow<'wa, str>,
53    },
54    #[error("Encountered an invalid ISO8601 timestamp")]
55    InvalidISO8601Timestamp(Cow<'wa, str>),
56    #[error("The message that was sent to be signed did not match the message that was received")]
57    MessageResponseMismatch,
58}