Skip to content

Commit cf58d70

Browse files
committed
web/error: add AxumNope::Unauthorized
1 parent aaf7ea5 commit cf58d70

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/web/error.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub enum AxumNope {
2828
VersionNotFound,
2929
#[error("Search yielded no results")]
3030
NoResults,
31+
#[error("Unauthorized: {0}")]
32+
Unauthorized(&'static str),
3133
#[error("internal error")]
3234
InternalError(anyhow::Error),
3335
#[error("bad request")]
@@ -93,6 +95,11 @@ impl AxumNope {
9395
message: Cow::Owned(source.to_string()),
9496
status: StatusCode::BAD_REQUEST,
9597
}),
98+
AxumNope::Unauthorized(what) => ErrorResponse::ErrorInfo(ErrorInfo {
99+
title: "Unauthorized",
100+
message: what.into(),
101+
status: StatusCode::UNAUTHORIZED,
102+
}),
96103
AxumNope::InternalError(source) => {
97104
crate::utils::report_error(&source);
98105
ErrorResponse::ErrorInfo(ErrorInfo {

0 commit comments

Comments
 (0)