Added expenses.

This commit is contained in:
2026-09-20 21:52:49 +02:00
parent 15b8ae8f62
commit b9d18c4dd1
8 changed files with 226 additions and 1 deletions
+12
View File
@@ -3,9 +3,12 @@ use axum::{
response::{IntoResponse, Response},
};
use crate::routes::dtos::expense::RecurringExpenseConversionError;
#[derive(Debug)]
pub enum AppError {
Database(sqlx::Error),
InvalidRecurringExpense(RecurringExpenseConversionError),
}
impl From<sqlx::Error> for AppError {
@@ -14,10 +17,19 @@ impl From<sqlx::Error> for AppError {
}
}
impl From<RecurringExpenseConversionError> for AppError {
fn from(error: RecurringExpenseConversionError) -> Self {
Self::InvalidRecurringExpense(error)
}
}
impl IntoResponse for AppError {
fn into_response(self) -> Response {
match self {
Self::Database(error) => tracing::error!(%error, "Database query failed"),
Self::InvalidRecurringExpense(error) => {
tracing::error!(%error, "Invalid recurring expense data")
}
}
(StatusCode::INTERNAL_SERVER_ERROR, "Internal server error").into_response()