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.