Human-readable error page on the consent page

This commit is contained in:
Quentin Gliech
2025-07-23 19:35:28 +02:00
parent 0730a3b18a
commit db27ffb0a2

View File

@@ -11,9 +11,9 @@ use axum::{
use axum_extra::TypedHeader;
use hyper::StatusCode;
use mas_axum_utils::{
GenericError, InternalError,
cookies::CookieJar,
csrf::{CsrfExt, ProtectedForm},
record_error,
};
use mas_data_model::AuthorizationGrantStage;
use mas_keystore::Keystore;
@@ -64,13 +64,15 @@ impl_from_error_for_route!(super::callback::CallbackDestinationError);
impl IntoResponse for RouteError {
fn into_response(self) -> axum::response::Response {
let sentry_event_id = record_error!(self, Self::Internal(_) | Self::NoSuchClient(_));
(
StatusCode::INTERNAL_SERVER_ERROR,
sentry_event_id,
self.to_string(),
)
.into_response()
match self {
Self::Internal(e) => InternalError::new(e).into_response(),
e @ Self::NoSuchClient(_) => InternalError::new(Box::new(e)).into_response(),
e @ Self::GrantNotFound => GenericError::new(StatusCode::NOT_FOUND, e).into_response(),
e @ Self::GrantNotPending(_) => {
GenericError::new(StatusCode::CONFLICT, e).into_response()
}
e @ Self::Csrf(_) => GenericError::new(StatusCode::BAD_REQUEST, e).into_response(),
}
}
}