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
Trait Implementations§
Source§impl Error for AppError
impl Error for AppError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl ForgeError for AppError
impl ForgeError for AppError
Source§fn is_retryable(&self) -> bool
fn is_retryable(&self) -> bool
Returns true if the operation can be retried
Source§fn is_fatal(&self) -> bool
fn is_fatal(&self) -> bool
Returns true if the error is fatal and should terminate the program
Source§fn status_code(&self) -> u16
fn status_code(&self) -> u16
Returns an appropriate HTTP status code for the error
Source§fn user_message(&self) -> String
fn user_message(&self) -> String
Returns a user-facing message that can be shown to end users
Source§fn dev_message(&self) -> String
fn dev_message(&self) -> String
Returns a detailed technical message for developers/logs
Auto Trait Implementations§
impl Freeze for AppError
impl !RefUnwindSafe for AppError
impl Send for AppError
impl Sync for AppError
impl Unpin for AppError
impl !UnwindSafe for AppError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more