Skip to main content

Error

Struct Error 

Source
pub struct Error { /* private fields */ }
Expand description

An error carrying a classified ErrorKind, a message, and an optional source.

Implementations§

Source§

impl Error

Source

pub fn new(kind: ErrorKind) -> Self

Creates an error of the given ErrorKind with an empty message.

Source

pub fn from_boxed(kind: ErrorKind, error: impl Into<BoxError>) -> Self

Wraps an arbitrary error under the given ErrorKind.

If the error already is an Error, it is returned unchanged and keeps its own kind.

Source

pub fn invalid(message: impl Into<String>) -> Self

Creates an Invalid error with a message.

Source

pub fn backend(message: impl Into<String>) -> Self

Creates a Backend error with a message.

Source

pub fn worker(message: impl Into<String>) -> Self

Creates a Worker error with a message.

Source

pub fn with_message(self, message: impl Into<String>) -> Self

Replaces the message.

Source

pub fn with_source(self, source: impl Into<BoxError>) -> Self

Attaches a source error.

Source

pub const fn with_status(self, status: StatusCode) -> Self

Attaches the response status that caused the error.

Source

pub fn with_uri(self, uri: Uri) -> Self

Attaches the URI of the request that failed.

Source

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.

Source

pub const fn kind(&self) -> ErrorKind

Returns the ErrorKind.

Source

pub fn message(&self) -> &str

Returns the message, which may be empty.

Source

pub const fn status(&self) -> Option<StatusCode>

Returns the response status that caused the error, if any.

Source

pub fn uri(&self) -> Option<&Uri>

Returns the URI of the request that failed, if known.

Source

pub const fn retry_after(&self) -> Option<Duration>

Returns how long to wait before retrying, if the remote said so.

Source

pub const fn is_retryable(&self) -> bool

Whether the failed operation is worth retrying.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<!> for Error

Source§

fn from(never: Infallible) -> Self

Converts to this type from the input type.
Source§

impl From<&Error> for Failure

Source§

fn from(error: &Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidUri> for Error

Source§

fn from(error: InvalidUri) -> Self

Converts to this type from the input type.
Source§

impl IntoOutcome for Error

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<W> WorkerExt for W

Source§

fn layer<C, M>(self, middleware: M) -> Layered<M, C>
where C: Send + 'static, Self: Worker<C>, M: Middleware<C>,

Wraps this worker in middleware, which runs before it, and before any middleware added earlier.