v0.12.0-preety_code
This commit is contained in:
+15
-4
@@ -1,4 +1,8 @@
|
||||
use axum::{http::StatusCode, response::{IntoResponse, Response}, Json};
|
||||
use axum::{
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
Json,
|
||||
};
|
||||
use serde_json::json;
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -28,7 +32,10 @@ impl IntoResponse for AppError {
|
||||
Self::Device(v) => (StatusCode::BAD_GATEWAY, v.clone()),
|
||||
Self::Internal(v) => {
|
||||
tracing::error!(error = ?v, "internal error");
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, "internal server error".into())
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
"internal server error".into(),
|
||||
)
|
||||
}
|
||||
};
|
||||
(status, Json(json!({"error": message}))).into_response()
|
||||
@@ -36,9 +43,13 @@ impl IntoResponse for AppError {
|
||||
}
|
||||
|
||||
impl From<rusqlite::Error> for AppError {
|
||||
fn from(value: rusqlite::Error) -> Self { Self::Internal(value.into()) }
|
||||
fn from(value: rusqlite::Error) -> Self {
|
||||
Self::Internal(value.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for AppError {
|
||||
fn from(value: serde_json::Error) -> Self { Self::Internal(value.into()) }
|
||||
fn from(value: serde_json::Error) -> Self {
|
||||
Self::Internal(value.into())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user