v0.12.0-preety_code

This commit is contained in:
Mateusz Gruszczyński
2026-09-03 15:33:37 +02:00
parent be67932b47
commit 07be4b85d9
87 changed files with 11691 additions and 3172 deletions
+15 -4
View File
@@ -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())
}
}