Skip to main content

google_jwt_auth/
error.rs

1use thiserror::Error;
2
3pub(crate) type Result<T> = std::result::Result<T, TokenGenerationError>;
4
5/// This error contains all predictable types of failures
6/// that can occur during the token generation/signing and requesting.
7#[derive(Debug, Error)]
8pub enum TokenGenerationError {
9    /// Invalid lifetime
10    #[error("The provided lifetime '{0}' is out of range 30..3600.")]
11    InvalidLifetime(i64),
12    /// `JsonWebToken` library error
13    #[error("JsonWebTokenError occurred: {0}")]
14    JsonWebTokenError(#[from] jsonwebtoken::errors::Error),
15    /// Reqwest library error
16    #[error("ReqwestError occurred: {0}")]
17    ReqwestError(#[from] reqwest::Error),
18    /// Serde library error
19    #[error("SerdeError occurred: {0}")]
20    SerdeError(#[from] serde_json::Error),
21    /// The authentication service responded with an error
22    #[error("The authentication service returned an error:\nType: {0}, Message: {1}")]
23    AuthenticationError(String, String),
24}