Struggling to clean up error handling.
This commit is contained in:
@@ -4,8 +4,6 @@ use axum::{
|
||||
response::IntoResponse,
|
||||
};
|
||||
|
||||
use crate::routes::extractors::auth::AuthError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AuthHeader {
|
||||
scheme: String,
|
||||
@@ -77,9 +75,21 @@ pub enum AuthHeaderError {
|
||||
EmptyToken,
|
||||
}
|
||||
|
||||
impl crate::error::ClientError for AuthHeaderError {
|
||||
fn client_error_message(&self) -> &'static str {
|
||||
match self {
|
||||
AuthHeaderError::Missing => "Missing authorization header",
|
||||
AuthHeaderError::NotAscii(_) => "Invalid authorization header encoding",
|
||||
AuthHeaderError::MalformedValue => "Malformed authorization header",
|
||||
AuthHeaderError::EmptyScheme => "Empty authorization scheme",
|
||||
AuthHeaderError::EmptyToken => "Empty authorization token",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoResponse for AuthHeaderError {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
Into::<AuthError>::into(self).into_response()
|
||||
Into::<super::AuthError>::into(self).into_response()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user