diff options
Diffstat (limited to 'server/src/errors.rs')
-rw-r--r-- | server/src/errors.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/server/src/errors.rs b/server/src/errors.rs new file mode 100644 index 0000000..6fd0a61 --- /dev/null +++ b/server/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() + } +} |