From 8b98590a1e64936e256abd648dc7fd430c220be3 Mon Sep 17 00:00:00 2001 From: GW_MC <72297530+GWMCwing@users.noreply.github.com> Date: Tue, 2 Dec 2025 16:55:08 +0800 Subject: [PATCH] Add service_error module for error handling --- apps/api/src/errors.rs | 1 + apps/api/src/errors/service_error.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 apps/api/src/errors.rs create mode 100644 apps/api/src/errors/service_error.rs diff --git a/apps/api/src/errors.rs b/apps/api/src/errors.rs new file mode 100644 index 0000000..ae13070 --- /dev/null +++ b/apps/api/src/errors.rs @@ -0,0 +1 @@ +pub mod service_error; diff --git a/apps/api/src/errors/service_error.rs b/apps/api/src/errors/service_error.rs new file mode 100644 index 0000000..ce8c3f8 --- /dev/null +++ b/apps/api/src/errors/service_error.rs @@ -0,0 +1,14 @@ +pub type ServiceError = Box; + +pub trait IntoServiceError { + fn into_service_error(self) -> ServiceError; +} + +impl IntoServiceError for T +where + T: std::error::Error + Send + Sync + 'static, +{ + fn into_service_error(self) -> ServiceError { + Box::new(self) + } +}