Skip to content

Commit 58c16a2

Browse files
committed
Human-readable error page on the upstream authorization page
1 parent 89a85a2 commit 58c16a2

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

crates/handlers/src/upstream_oauth2/authorize.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use axum::{
99
response::{IntoResponse, Redirect},
1010
};
1111
use hyper::StatusCode;
12-
use mas_axum_utils::{cookies::CookieJar, record_error};
12+
use mas_axum_utils::{GenericError, InternalError, cookies::CookieJar};
1313
use mas_data_model::UpstreamOAuthProvider;
1414
use mas_oidc_client::requests::authorization_code::AuthorizationRequestData;
1515
use mas_router::{PostAuthAction, UrlBuilder};
@@ -41,13 +41,12 @@ impl_from_error_for_route!(mas_storage::RepositoryError);
4141

4242
impl IntoResponse for RouteError {
4343
fn into_response(self) -> axum::response::Response {
44-
let sentry_event_id = record_error!(self, Self::Internal(_));
45-
let response = match self {
46-
Self::ProviderNotFound => (StatusCode::NOT_FOUND, "Provider not found").into_response(),
47-
Self::Internal(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
48-
};
49-
50-
(sentry_event_id, response).into_response()
44+
match self {
45+
e @ Self::ProviderNotFound => {
46+
GenericError::new(StatusCode::NOT_FOUND, e).into_response()
47+
}
48+
Self::Internal(e) => InternalError::new(e).into_response(),
49+
}
5150
}
5251
}
5352

0 commit comments

Comments
 (0)