diff options
author | Santo Cariotti <santo@dcariotti.me> | 2022-08-21 18:32:56 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2022-08-21 18:32:56 +0200 |
commit | 66e677a8543285ed424d616092fb09c518b32fa4 (patch) | |
tree | a4978e1298ce7c131cd25701e02cdbe24e2f15ad /src/errors.rs |
Init
Diffstat (limited to 'src/errors.rs')
-rw-r--r-- | src/errors.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/errors.rs b/src/errors.rs new file mode 100644 index 0000000..6fd0a61 --- /dev/null +++ b/src/errors.rs @@ -0,0 +1,24 @@ +use axum::{ + http::StatusCode, + response::{IntoResponse, Response}, + Json, +}; +use serde_json::json; + +pub enum Error { + Generic, +} + +impl IntoResponse for Error { + fn into_response(self) -> Response { + let (status, error_message) = match self { + Error::Generic => (StatusCode::INTERNAL_SERVER_ERROR, "User not found"), + }; + + let body = Json(json!({ + "error": error_message, + })); + + (status, body).into_response() + } +} |