move bin
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-11-06 00:45:47 +01:00
parent 685b17a607
commit 784435897b
7 changed files with 46 additions and 41 deletions

22
src/error.rs Normal file
View File

@@ -0,0 +1,22 @@
use axum::{http::StatusCode, response::IntoResponse, Json};
use serde_json::json;
#[allow(dead_code)]
#[derive(Debug)]
pub enum AppError {
WrongCredentials,
InternalServerError,
}
impl IntoResponse for AppError {
fn into_response(self) -> axum::response::Response {
let (status, err_msg) = match self {
Self::WrongCredentials => (StatusCode::BAD_REQUEST, "invalid credentials"),
Self::InternalServerError => (
StatusCode::INTERNAL_SERVER_ERROR,
"something went wrong with your request",
),
};
(status, Json(json!({ "error": err_msg }))).into_response()
}
}