pub struct CodedError<E> {
pub error: E,
pub code: String,
pub fatal: bool,
}
Expand description
An error with an associated error code
Fields§
§error: E
The original error
code: String
The error code
fatal: bool
Whether this error is fatal
Implementations§
Source§impl<E> CodedError<E>
impl<E> CodedError<E>
Sourcepub fn code_info(&self) -> Option<ErrorCodeInfo>
pub fn code_info(&self) -> Option<ErrorCodeInfo>
Get information about this error code from the registry
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
Trait Implementations§
Source§impl<E: Debug> Debug for CodedError<E>
impl<E: Debug> Debug for CodedError<E>
Source§impl<E: Display> Display for CodedError<E>
impl<E: Display> Display for CodedError<E>
Source§impl<E: Error + 'static> Error for CodedError<E>
impl<E: Error + 'static> Error for CodedError<E>
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<E: ForgeError> ForgeError for CodedError<E>
impl<E: ForgeError> ForgeError for CodedError<E>
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<E> Freeze for CodedError<E>where
E: Freeze,
impl<E> RefUnwindSafe for CodedError<E>where
E: RefUnwindSafe,
impl<E> Send for CodedError<E>where
E: Send,
impl<E> Sync for CodedError<E>where
E: Sync,
impl<E> Unpin for CodedError<E>where
E: Unpin,
impl<E> UnwindSafe for CodedError<E>where
E: UnwindSafe,
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