From 089de9ef8f2692355f26f0c4d6baa437bb0ba5a8 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Wed, 23 Jul 2025 19:36:17 +0200 Subject: [PATCH] Human-readable error page on the upstream authorization page --- crates/handlers/src/upstream_oauth2/authorize.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/handlers/src/upstream_oauth2/authorize.rs b/crates/handlers/src/upstream_oauth2/authorize.rs index 4168fc49e..016dd36d3 100644 --- a/crates/handlers/src/upstream_oauth2/authorize.rs +++ b/crates/handlers/src/upstream_oauth2/authorize.rs @@ -9,7 +9,7 @@ use axum::{ response::{IntoResponse, Redirect}, }; use hyper::StatusCode; -use mas_axum_utils::{cookies::CookieJar, record_error}; +use mas_axum_utils::{GenericError, InternalError, cookies::CookieJar}; use mas_data_model::UpstreamOAuthProvider; use mas_oidc_client::requests::authorization_code::AuthorizationRequestData; use mas_router::{PostAuthAction, UrlBuilder}; @@ -41,13 +41,12 @@ impl_from_error_for_route!(mas_storage::RepositoryError); impl IntoResponse for RouteError { fn into_response(self) -> axum::response::Response { - let sentry_event_id = record_error!(self, Self::Internal(_)); - let response = match self { - Self::ProviderNotFound => (StatusCode::NOT_FOUND, "Provider not found").into_response(), - Self::Internal(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(), - }; - - (sentry_event_id, response).into_response() + match self { + e @ Self::ProviderNotFound => { + GenericError::new(StatusCode::NOT_FOUND, e).into_response() + } + Self::Internal(e) => InternalError::new(e).into_response(), + } } }