Added expenses.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user