diff options
author | Cara Salter <cara@devcara.com> | 2022-06-09 10:28:42 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2022-06-09 10:28:42 -0400 |
commit | 276255f5a20fa05a005e765287239ca5ffe439e4 (patch) | |
tree | 67e325727fe49004d54deee702fb556a7d5ce1f1 /src/errors.rs | |
parent | bb545403fed8af5b746778c3336a4f3a371148d6 (diff) | |
download | solard-276255f5a20fa05a005e765287239ca5ffe439e4.tar.gz solard-276255f5a20fa05a005e765287239ca5ffe439e4.zip |
planets: State manipulation
Diffstat (limited to 'src/errors.rs')
-rw-r--r-- | src/errors.rs | 10 |
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() } |