pub struct Error { /* private fields */ }Expand description
An error encountered when communicating with the service.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new<E>(kind: ErrorKind, error: E) -> Self
pub fn new<E>(kind: ErrorKind, error: E) -> Self
Create a new Error based on an ErrorKind and an underlying error cause.
Sourcepub fn with_error<E, C>(kind: ErrorKind, error: E, message: C) -> Self
pub fn with_error<E, C>(kind: ErrorKind, error: E, message: C) -> Self
Create a new Error based on an ErrorKind, an underlying error cause, and a message.
Sourcepub fn with_error_fn<E, F, C>(kind: ErrorKind, error: E, f: F) -> Self
pub fn with_error_fn<E, F, C>(kind: ErrorKind, error: E, f: F) -> Self
Create a new Error based on an ErrorKind, an underlying error cause, and a function that returns a message.
Sourcepub fn with_message<C>(kind: ErrorKind, message: C) -> Self
pub fn with_message<C>(kind: ErrorKind, message: C) -> Self
Create an Error based on an ErrorKind and a message.
Sourcepub fn with_message_fn<F, C>(kind: ErrorKind, f: F) -> Self
pub fn with_message_fn<F, C>(kind: ErrorKind, f: F) -> Self
Creates an Error based on an ErrorKind and a function that returns a message.
Sourcepub fn with_context<C>(self, message: C) -> Self
pub fn with_context<C>(self, message: C) -> Self
Wrap this error with an additional message.
Sourcepub fn with_context_fn<F, C>(self, f: F) -> Self
pub fn with_context_fn<F, C>(self, f: F) -> Self
Wrap this error with an additional message returned from a function.
Sourcepub fn http_status(&self) -> Option<StatusCode>
pub fn http_status(&self) -> Option<StatusCode>
If this error is an HTTP response error, return the associated status code.
Sourcepub fn into_inner(self) -> Result<Box<dyn Error + Send + Sync>, Self>
pub fn into_inner(self) -> Result<Box<dyn Error + Send + Sync>, Self>
Consumes the Error, returning its inner error, if any.
Sourcepub fn into_downcast<T: Error + 'static>(self) -> Result<T, Self>
pub fn into_downcast<T: Error + 'static>(self) -> Result<T, Self>
Consumes the error, attempting to downcast the inner error as the type provided.
Returns Err(self) if the downcast is not possible.
Sourcepub fn get_ref(&self) -> Option<&(dyn Error + Send + Sync + 'static)>
pub fn get_ref(&self) -> Option<&(dyn Error + Send + Sync + 'static)>
Returns a reference to the inner error wrapped by this error, if any.
Sourcepub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T>
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T>
Returns a reference to the inner error, if any, downcast to the type provided.
Sourcepub fn get_mut(&mut self) -> Option<&mut (dyn Error + Send + Sync + 'static)>
pub fn get_mut(&mut self) -> Option<&mut (dyn Error + Send + Sync + 'static)>
Returns a mutable reference to the inner error wrapped by this error, if any.
Sourcepub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T>
pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T>
Returns a mutable reference to the inner error, if any, downcasting to the type provided.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()