aboutsummaryrefslogtreecommitdiff
path: root/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/errors.rs')
-rw-r--r--src/errors.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/errors.rs b/src/errors.rs
index d76db92..b22932f 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -12,6 +12,9 @@ pub enum ServiceError {
#[error("Axum error: {0}")]
Axum(#[from] axum::Error),
+
+ #[error("Not Found")]
+ NotFound,
}
pub type StringResult<T = &'static str> = std::result::Result<T, ServiceError>;
@@ -23,8 +26,13 @@ impl IntoResponse for ServiceError {
fn into_response(self) -> Response {
let body = body::boxed(body::Full::from(self.to_string()));
+
+ let status = match self {
+ ServiceError::NotFound => StatusCode::NOT_FOUND,
+ _ => StatusCode::INTERNAL_SERVER_ERROR,
+ };
Response::builder()
- .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .status(status)
.body(body)
.unwrap()
}