From 451d1db821b8d445f1bb6f1f3ad6de20f19eb85d Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 21 Aug 2022 18:48:51 +0200 Subject: Move backend to server folder --- server/src/errors.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 server/src/errors.rs (limited to 'server/src/errors.rs') 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() + } +} -- cgit v1.2.3-18-g5258