improve error logging
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
use axum::response::IntoResponse;
|
||||
use sea_orm::DbErr;
|
||||
use tracing::error;
|
||||
|
||||
use crate::errors::service_error::ServiceError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ApiError {
|
||||
ServiceError(ServiceError),
|
||||
}
|
||||
|
||||
impl From<ServiceError> for ApiError {
|
||||
fn from(err: ServiceError) -> Self {
|
||||
error!("Service error occurred: {:?}", err);
|
||||
ApiError::ServiceError(err)
|
||||
}
|
||||
}
|
||||
@@ -21,6 +24,7 @@ impl From<DbErr> for ApiError {
|
||||
|
||||
impl IntoResponse for ApiError {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
error!("API error occurred: {:?}", self);
|
||||
match self {
|
||||
ApiError::ServiceError(service_error) => service_error.into_response(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user