Struggling to clean up error handling.

This commit is contained in:
2026-10-10 17:18:36 +02:00
parent 5f85713892
commit 94b2f23a59
4 changed files with 64 additions and 48 deletions
+13 -3
View File
@@ -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()
}
}