mauth_core/
error.rs

1use thiserror::Error;
2
3/// All of the possible errors that can happen while performing mauth operations
4#[derive(Debug, Error)]
5pub enum Error {
6    /// A UTF8 decode error while attempting to process the URL
7    #[error("Unable to handle the URL as the format was invalid: {0}")]
8    UrlEncodingError(#[from] std::string::FromUtf8Error),
9    /// A MAuth version that is not supported was requested
10    #[error("Version {0} is not supported")]
11    UnsupportedVersion(u8),
12    /// The provided private key could not be parsed
13    #[error("Unable to parse RSA private key: {0}")]
14    PrivateKeyDecodeError(#[from] rsa::pkcs1::Error),
15    /// The provided public key could not be parsed
16    #[error("Unable to parse RSA public key: {0}")]
17    PublicKeyDecodeError(#[from] spki::Error),
18    /// An algorithm failure occurred while trying to sign a request
19    #[error("RSA algorithm error: {0}")]
20    RsaSignError(#[from] rsa::Error),
21    /// An algorithm failure occurred while trying to verify a request
22    #[error("Unable to verify RSA signature: {0}")]
23    SignatureVerifyError(#[from] rsa::signature::Error),
24    /// A base64 error was encountered while attempting to verify a v1 signature
25    #[error("Unable to decode base64-encoded signature: {0}")]
26    SignatureDecodeError(#[from] base64::DecodeError),
27}