Skip to content

Commit

Permalink
web/error: add AxumNope::Unauthorized
Browse files Browse the repository at this point in the history
  • Loading branch information
pflanze committed Jul 11, 2024
1 parent aaf7ea5 commit cf58d70
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/web/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub enum AxumNope {
VersionNotFound,
#[error("Search yielded no results")]
NoResults,
#[error("Unauthorized: {0}")]
Unauthorized(&'static str),
#[error("internal error")]
InternalError(anyhow::Error),
#[error("bad request")]
Expand Down Expand Up @@ -93,6 +95,11 @@ impl AxumNope {
message: Cow::Owned(source.to_string()),
status: StatusCode::BAD_REQUEST,
}),
AxumNope::Unauthorized(what) => ErrorResponse::ErrorInfo(ErrorInfo {
title: "Unauthorized",
message: what.into(),
status: StatusCode::UNAUTHORIZED,
}),
AxumNope::InternalError(source) => {
crate::utils::report_error(&source);
ErrorResponse::ErrorInfo(ErrorInfo {
Expand Down

0 comments on commit cf58d70

Please sign in to comment.