pub struct Error<E> { /* private fields */ }Expand description
An error container.
Error<E> is a lightweight handle to an error that can be cheaply cloned.
It is Send and Sync when E is. It preserves the original error along
with associated context such as the location where it occurred, the responsible
service, a tag, a backtrace, and extension data.
Implementations§
Source§impl<E> Error<E>
impl<E> Error<E>
Sourcepub fn new<T>(error: T, service: &'static str) -> Error<E>where
E: From<T>,
pub fn new<T>(error: T, service: &'static str) -> Error<E>where
E: From<T>,
Creates an error container associated with a service.
Captures the caller location and associates the error with a service.
Sourcepub fn from_err<T>(error: T) -> Error<E>where
E: From<T>,
pub fn from_err<T>(error: T) -> Error<E>where
E: From<T>,
Creates an error container without service attribution.
Captures the caller location.
Source§impl<E> Error<E>where
E: Clone,
impl<E> Error<E>where
E: Clone,
Sourcepub fn with_tag<T>(self, tag: T) -> Error<E>
pub fn with_tag<T>(self, tag: T) -> Error<E>
Sets a user-defined tag on this error.
Returns the updated error.
Sourcepub fn with_service(self, name: &'static str) -> Error<E>
pub fn with_service(self, name: &'static str) -> Error<E>
Sets the service responsible for this error.
Returns the updated error.
Sourcepub fn map<U, F>(self, f: F) -> Error<U>where
F: FnOnce(E) -> U,
pub fn map<U, F>(self, f: F) -> Error<U>where
F: FnOnce(E) -> U,
Maps the inner error into a new error type using the provided closure.
Preserves tag, service, backtrace, and extension data.
Sourcepub fn map_err<U>(self) -> Error<U>where
U: From<E>,
pub fn map_err<U>(self) -> Error<U>where
U: From<E>,
Converts the inner error into a new error type via U: From<E>.
Preserves tag, service, backtrace, and extension data.
Sourcepub fn try_map<T, U, F>(self, f: F) -> Result<T, Error<U>>
pub fn try_map<T, U, F>(self, f: F) -> Result<T, Error<U>>
Tries to map the inner error into a value or another error type.
On error, preserves tag, service, backtrace, and extension data.
Sourcepub fn into_error(self) -> E
pub fn into_error(self) -> E
Consumes this error and returns the inner error value.
Trait Implementations§
Source§impl<E> AsError for Error<E>where
E: ErrorDiagnostic,
impl<E> AsError for Error<E>where
E: ErrorDiagnostic,
impl<E> Eq for Error<E>where
E: Eq,
Source§impl<E> Error for Error<E>where
E: Error + 'static,
impl<E> Error for Error<E>where
E: Error + 'static,
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()
Source§impl<E> ErrorDiagnostic for Error<E>where
E: ErrorDiagnostic,
impl<E> ErrorDiagnostic for Error<E>where
E: ErrorDiagnostic,
Source§impl<E> Retryable for Error<E>where
E: Retryable,
impl<E> Retryable for Error<E>where
E: Retryable,
Source§fn is_retryable(&self) -> bool
fn is_retryable(&self) -> bool
true if the failed operation can be retried.Source§impl<E, St, Err> WebResponseError<St, Err> for Error<E>where
E: WebResponseError<St, Err> + Clone,
impl<E, St, Err> WebResponseError<St, Err> for Error<E>where
E: WebResponseError<St, Err> + Clone,
Source§fn error_response(&self, st: &St) -> HttpResponse
fn error_response(&self, st: &St) -> HttpResponse
Auto Trait Implementations§
impl<E> !RefUnwindSafe for Error<E>
impl<E> !UnwindSafe for Error<E>
impl<E> Freeze for Error<E>
impl<E> Send for Error<E>
impl<E> Sync for Error<E>
impl<E> Unpin for Error<E>
impl<E> UnsafeUnpin for Error<E>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.