1#[derive(thiserror::Error, Debug)]
2pub enum Error {
3 #[error(transparent)]
4 TimeError(#[from] std::time::SystemTimeError),
5 #[error(transparent)]
6 JwtError(#[from] jsonwebtoken::errors::Error),
7 #[error(transparent)]
8 Utf8Error(#[from] std::str::Utf8Error),
9 #[error(transparent)]
10 RsaPkcs1Error(#[from] rsa::pkcs1::Error),
11 #[error(transparent)]
12 RsaError(#[from] rsa::errors::Error),
13 #[error(transparent)]
14 JsonError(#[from] serde_json::Error),
15 #[error(transparent)]
16 DecodeError(#[from] base64::DecodeError),
17}
18
19pub type Result<T> = std::result::Result<T, Error>;
20
21impl axum::response::IntoResponse for Error {
22 fn into_response(self) -> axum::response::Response {
23 let status = match self {
24 Error::JwtError(_) => axum::http::StatusCode::UNAUTHORIZED,
25 _ => axum::http::StatusCode::INTERNAL_SERVER_ERROR,
26 };
27
28 (status, self.to_string()).into_response()
29 }
30}