summaryrefslogtreecommitdiff
path: root/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/errors.rs')
-rw-r--r--src/errors.rs24
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()
+ }
+}