summaryrefslogtreecommitdiff
path: root/server/src/error.rs
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2022-10-14 19:07:14 -0400
committerKjetil Orbekk <kj@orbekk.com>2022-10-14 19:07:14 -0400
commit58f91c62065d9a7e37c953503100b87b506297e7 (patch)
tree9e43fb45702d06366af015151f8ea4613e46e08a /server/src/error.rs
parent1e0ceb4b7c714430ff42a1c98d416246f035d75f (diff)
Automatically log in again when token refresh fails
Diffstat (limited to 'server/src/error.rs')
-rw-r--r--server/src/error.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/server/src/error.rs b/server/src/error.rs
index aef2687..9d82a54 100644
--- a/server/src/error.rs
+++ b/server/src/error.rs
@@ -1,4 +1,7 @@
-use axum::{http::{StatusCode, self}, response::IntoResponse};
+use axum::{
+ http::{self, StatusCode},
+ response::IntoResponse,
+};
use openidconnect::{core::CoreErrorResponseType, ClaimsVerificationError, StandardErrorResponse};
use tracing::error;
@@ -47,13 +50,18 @@ pub enum BridgeError {
impl BridgeError {
pub fn as_rejection(&self) -> (http::StatusCode, String) {
- (StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}"))
+ match self {
+ BridgeError::OpenidRequestTokenError(_) => {
+ (StatusCode::UNAUTHORIZED, format!("Error fetching token"))
+ }
+ _ => (StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}")),
+ }
}
}
impl IntoResponse for BridgeError {
fn into_response(self) -> axum::response::Response {
error!("Error occurred: {self:?}");
- self.as_rejection().into_response()
+ self.as_rejection().into_response()
}
}