diff options
Diffstat (limited to 'src/error/error_type.rs')
-rw-r--r-- | src/error/error_type.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/error/error_type.rs b/src/error/error_type.rs index 9eef287..4913d76 100644 --- a/src/error/error_type.rs +++ b/src/error/error_type.rs @@ -9,12 +9,20 @@ pub struct AppError { _cause: String, } -#[allow(dead_code)] impl AppError { pub fn new(_kind: AppErrorKind, _cause: String) -> Self { Self { _kind, _cause } } + pub fn error(cause: impl ToString) -> Self { + Self::new(AppErrorKind::UnknownError, cause.to_string()) + } + + pub fn fail<T>(cause: impl ToString) -> Result<T, AppError> { + Err(Self::error(cause)) + } + + #[allow(dead_code)] pub fn kind(&self) -> &AppErrorKind { &self._kind } |