summaryrefslogtreecommitdiff
path: root/server/src/errors.rs
blob: 6fd0a611cb3dc7ba035eca6538d171e3b9545e79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()
    }
}