feat: implement conversion from DbErr to ApiError

This commit is contained in:
GW_MC
2025-12-31 14:51:22 +08:00
parent d81e5fe48d
commit 4f85d88380

View File

@@ -1,4 +1,5 @@
use axum::response::IntoResponse; use axum::response::IntoResponse;
use sea_orm::DbErr;
use crate::errors::service_error::ServiceError; use crate::errors::service_error::ServiceError;
@@ -12,6 +13,12 @@ impl From<ServiceError> for ApiError {
} }
} }
impl From<DbErr> for ApiError {
fn from(err: DbErr) -> Self {
ServiceError::from(err).into()
}
}
impl IntoResponse for ApiError { impl IntoResponse for ApiError {
fn into_response(self) -> axum::response::Response { fn into_response(self) -> axum::response::Response {
match self { match self {