Skip to main content

TransportError

Enum TransportError 

Source
pub enum TransportError {
    InvalidPath {
        path: String,
        source: ParseError,
    },
    Unreachable {
        request: RequestLabel,
        source: Error,
    },
    CredentialRejected {
        request: RequestLabel,
    },
    NotFound {
        request: RequestLabel,
    },
    RateLimited {
        request: RequestLabel,
        wait: Option<Duration>,
    },
    RateLimitWaitTooLong {
        request: RequestLabel,
        wait: Duration,
    },
    Rejected {
        request: RequestLabel,
        status: u16,
        body: String,
    },
    Unexpected {
        request: RequestLabel,
        status: u16,
        body: String,
    },
    TooManyPages {
        request: RequestLabel,
        limit: usize,
    },
    Malformed {
        request: RequestLabel,
        source: Box<DeserializeError>,
    },
}
Expand description

Anything that stops a request from producing a usable answer.

Headers are never included in any variant, so a credential cannot reach a log or an error message through here.

Variants§

§

InvalidPath

The request path does not join cleanly onto the transport base.

Fields

§path: String

The path passed to the request method.

§source: ParseError

The failure Url::join reported.

§

Unreachable

The request never reached the forge, or no answer came back.

Fields

§request: RequestLabel

The method and path that were attempted.

§source: Error

The underlying transport failure.

§

CredentialRejected

The credential is missing or invalid (401).

Fields

§request: RequestLabel

The method and path that were attempted.

§

NotFound

The addressed resource is not there (404).

Fields

§request: RequestLabel

The method and path that were attempted.

§

RateLimited

The forge asked the caller to slow down (429, or a 403 that carries rate limit headers).

Fields

§request: RequestLabel

The method and path that were attempted.

§wait: Option<Duration>

How long the forge asked the caller to wait, when it said.

§

RateLimitWaitTooLong

The forge asked for a longer wait than this transport honours.

Fields

§request: RequestLabel

The method and path that were attempted.

§wait: Duration

How long the forge asked the caller to wait.

§

Rejected

The forge read the request and refused it (400, 403, or 422).

Fields

§request: RequestLabel

The method and path that were attempted.

§status: u16

The HTTP status the forge answered with.

§body: String

The response body, summarized for the error message.

§

Unexpected

A status this transport does not otherwise classify, including a server error (5xx) that survived every retry.

Fields

§request: RequestLabel

The method and path that were attempted.

§status: u16

The HTTP status the forge answered with.

§body: String

The response body, summarized for the error message.

§

TooManyPages

A listing still had more pages after the page limit.

Fields

§request: RequestLabel

The method and path of the first page.

§limit: usize

The page limit that was exceeded.

§

Malformed

The forge answered successfully, but the body does not decode.

Fields

§request: RequestLabel

The method and path that were attempted.

§source: Box<DeserializeError>

The decoding failure.

Implementations§

Source§

impl TransportError

Source

pub const fn request(&self) -> Option<&RequestLabel>

The request that failed, when the failure belongs to one.

Source

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

The wait the forge asked for before a retry.

Source

pub const fn is_uncertain(&self) -> bool

Whether the forge may or may not have applied the request.

That is a connection failure or a 5xx answer.

Source

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

The HTTP status of a failure that carries one.

Source

fn from_status( request: RequestLabel, status: u16, body: String, wait: Option<Duration>, ) -> Self

Map a status, body, and the wait its headers ask for to the failure class it represents.

Trait Implementations§

Source§

impl Debug for TransportError

Source§

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

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

impl Display for TransportError

Source§

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

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

impl Error for TransportError

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

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

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
§

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

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