pub enum AppError {
Config {
message: String,
retryable: bool,
fatal: bool,
status: u16,
},
Filesystem {
path: Option<PathBuf>,
source: Error,
retryable: bool,
fatal: bool,
status: u16,
},
Network {
endpoint: String,
source: Option<Box<dyn StdError + Send + Sync>>,
retryable: bool,
fatal: bool,
status: u16,
},
Other {
message: String,
retryable: bool,
fatal: bool,
status: u16,
},
}Expand description
Example error enum that can be replaced by the define_errors! macro.
Variants§
Config
Configuration-related errors
Filesystem
Filesystem-related errors with optional path and source error
Network
Network-related errors
Fields
Other
Generic errors for anything not covered by specific variants
Implementations§
Source§impl AppError
Constructor methods for AppError
impl AppError
Constructor methods for AppError
Sourcepub fn filesystem(
path: impl Into<String>,
source: impl Into<Option<Error>>,
) -> Self
pub fn filesystem( path: impl Into<String>, source: impl Into<Option<Error>>, ) -> Self
Create a new Filesystem error
Sourcepub fn filesystem_with_source(path: impl Into<PathBuf>, source: Error) -> Self
pub fn filesystem_with_source(path: impl Into<PathBuf>, source: Error) -> Self
Create a filesystem error with specific source error
Sourcepub fn network(
endpoint: impl Into<String>,
source: impl Into<Option<Box<dyn StdError + Send + Sync>>>,
) -> Self
pub fn network( endpoint: impl Into<String>, source: impl Into<Option<Box<dyn StdError + Send + Sync>>>, ) -> Self
Create a new Network error
Sourcepub fn network_with_source(
endpoint: impl Into<String>,
source: Option<Box<dyn StdError + Send + Sync>>,
) -> Self
pub fn network_with_source( endpoint: impl Into<String>, source: Option<Box<dyn StdError + Send + Sync>>, ) -> Self
Create a network error with specific source error
Sourcepub fn with_retryable(self, retryable: bool) -> Self
pub fn with_retryable(self, retryable: bool) -> Self
Set whether this error is retryable
Sourcepub fn with_fatal(self, fatal: bool) -> Self
pub fn with_fatal(self, fatal: bool) -> Self
Set whether this error is fatal
Sourcepub fn with_status(self, status: u16) -> Self
pub fn with_status(self, status: u16) -> Self
Set the HTTP status code for this error
Sourcepub fn with_code(self, code: impl Into<String>) -> CodedError<Self>
pub fn with_code(self, code: impl Into<String>) -> CodedError<Self>
Add a code to this error
Source§impl AppError
impl AppError
Sourcepub async fn from_async_result<T, E>(result: Result<T, E>) -> Result<T, Self>
pub async fn from_async_result<T, E>(result: Result<T, E>) -> Result<T, Self>
Create a new error from an async operation result
Sourcepub async fn handle_async(&self) -> Result<(), Box<dyn StdError + Send + Sync>>
pub async fn handle_async(&self) -> Result<(), Box<dyn StdError + Send + Sync>>
Handle this error asynchronously using the AsyncForgeError trait
Sourcepub fn with_async_context<C: Display + Debug + Send + Sync + 'static>(
self,
context_generator: impl FnOnce() -> C + Send + 'static,
) -> ContextError<Self, C>
pub fn with_async_context<C: Display + Debug + Send + Sync + 'static>( self, context_generator: impl FnOnce() -> C + Send + 'static, ) -> ContextError<Self, C>
Wrap this error with async context
Trait Implementations§
Source§impl AsyncForgeError for AppError
Provides async implementations for the AppError type.
impl AsyncForgeError for AppError
Provides async implementations for the AppError type.
Source§fn is_retryable(&self) -> bool
fn is_retryable(&self) -> bool
Source§fn is_fatal(&self) -> bool
fn is_fatal(&self) -> bool
Source§fn status_code(&self) -> u16
fn status_code(&self) -> u16
Source§fn user_message(&self) -> String
fn user_message(&self) -> String
Source§fn dev_message(&self) -> String
fn dev_message(&self) -> String
Source§fn async_handle<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn async_handle<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl Error for AppError
impl Error for AppError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()