pub struct Error { /* private fields */ }Expand description
An error carrying a classified ErrorKind, a message, and an optional
source.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(kind: ErrorKind) -> Self
pub fn new(kind: ErrorKind) -> Self
Creates an error of the given ErrorKind with an empty message.
Sourcepub fn from_boxed(kind: ErrorKind, error: impl Into<BoxError>) -> Self
pub fn from_boxed(kind: ErrorKind, error: impl Into<BoxError>) -> Self
Sourcepub fn with_message(self, message: impl Into<String>) -> Self
pub fn with_message(self, message: impl Into<String>) -> Self
Replaces the message.
Sourcepub fn with_source(self, source: impl Into<BoxError>) -> Self
pub fn with_source(self, source: impl Into<BoxError>) -> Self
Attaches a source error.
Sourcepub const fn with_status(self, status: StatusCode) -> Self
pub const fn with_status(self, status: StatusCode) -> Self
Attaches the response status that caused the error.
Sourcepub const fn with_retry_after(self, delay: Duration) -> Self
pub const fn with_retry_after(self, delay: Duration) -> Self
Asks for the failed request’s tag to be paused for delay before it
is retried, e.g. from a Retry-After header.
Sourcepub const fn status(&self) -> Option<StatusCode>
pub const fn status(&self) -> Option<StatusCode>
Returns the response status that caused the error, if any.
Sourcepub const fn retry_after(&self) -> Option<Duration>
pub const fn retry_after(&self) -> Option<Duration>
Returns how long to wait before retrying, if the remote said so.
Sourcepub const fn is_retryable(&self) -> bool
pub const fn is_retryable(&self) -> bool
Whether the failed operation is worth retrying.
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)>
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 From<!> for Error
impl From<!> for Error
Source§fn from(never: Infallible) -> Self
fn from(never: Infallible) -> Self
Converts to this type from the input type.
Source§impl From<InvalidUri> for Error
impl From<InvalidUri> for Error
Source§fn from(error: InvalidUri) -> Self
fn from(error: InvalidUri) -> Self
Converts to this type from the input type.
Source§impl IntoOutcome for Error
impl IntoOutcome for Error
Source§fn into_outcome(self) -> Outcome
fn into_outcome(self) -> Outcome
Converts
self into an Outcome.Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
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