Add service_error module for error handling
This commit is contained in:
1
apps/api/src/errors.rs
Normal file
1
apps/api/src/errors.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod service_error;
|
||||||
14
apps/api/src/errors/service_error.rs
Normal file
14
apps/api/src/errors/service_error.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
pub type ServiceError = Box<dyn std::error::Error + Send + Sync>;
|
||||||
|
|
||||||
|
pub trait IntoServiceError {
|
||||||
|
fn into_service_error(self) -> ServiceError;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> IntoServiceError for T
|
||||||
|
where
|
||||||
|
T: std::error::Error + Send + Sync + 'static,
|
||||||
|
{
|
||||||
|
fn into_service_error(self) -> ServiceError {
|
||||||
|
Box::new(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user