feat: introduce ApiError for improved error handling in upstream routes
This commit is contained in:
21
apps/api/src/errors/api_error.rs
Normal file
21
apps/api/src/errors/api_error.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use axum::response::IntoResponse;
|
||||
|
||||
use crate::errors::service_error::ServiceError;
|
||||
|
||||
pub enum ApiError {
|
||||
ServiceError(ServiceError),
|
||||
}
|
||||
|
||||
impl From<ServiceError> for ApiError {
|
||||
fn from(err: ServiceError) -> Self {
|
||||
ApiError::ServiceError(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoResponse for ApiError {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
match self {
|
||||
ApiError::ServiceError(service_error) => service_error.into_response(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user