summaryrefslogtreecommitdiff
path: root/server/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/error.rs')
-rw-r--r--server/src/error.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/server/src/error.rs b/server/src/error.rs
index cea23e7..aef2687 100644
--- a/server/src/error.rs
+++ b/server/src/error.rs
@@ -1,4 +1,4 @@
-use axum::{http::StatusCode, response::IntoResponse};
+use axum::{http::{StatusCode, self}, response::IntoResponse};
use openidconnect::{core::CoreErrorResponseType, ClaimsVerificationError, StandardErrorResponse};
use tracing::error;
@@ -26,6 +26,9 @@ pub enum BridgeError {
#[error("Unexpected authorization error")]
UnexpectedInvalidAuthorization(#[from] ClaimsVerificationError),
+ #[error("User is not logged in")]
+ NotLoggedIn,
+
#[error("Authentication error")]
SigningFailed(#[from] openidconnect::SigningError),
@@ -42,9 +45,15 @@ pub enum BridgeError {
DurationOutOfRange(#[from] time::OutOfRangeError),
}
+impl BridgeError {
+ pub fn as_rejection(&self) -> (http::StatusCode, String) {
+ (StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}"))
+ }
+}
+
impl IntoResponse for BridgeError {
fn into_response(self) -> axum::response::Response {
error!("Error occurred: {self:?}");
- (StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}")).into_response()
+ self.as_rejection().into_response()
}
}