aboutsummaryrefslogtreecommitdiff
path: root/src/errors.rs
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-06-09 10:28:42 -0400
committerCara Salter <cara@devcara.com>2022-06-09 10:28:42 -0400
commit276255f5a20fa05a005e765287239ca5ffe439e4 (patch)
tree67e325727fe49004d54deee702fb556a7d5ce1f1 /src/errors.rs
parentbb545403fed8af5b746778c3336a4f3a371148d6 (diff)
downloadsolard-276255f5a20fa05a005e765287239ca5ffe439e4.tar.gz
solard-276255f5a20fa05a005e765287239ca5ffe439e4.zip
planets: State manipulation
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()
}