Skip to main content

TransportError

Struct TransportError 

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

The failure an super::HttpBackend reports, or an super::HttpBody yields while it is read, carrying the taxonomy class it belongs to; and the payload of the transport-layer variants that keep it (taxonomy #2 / #9).

A backend picks the class through the constructor it builds the error with, and the runtime’s send maps the error to that class’s Error variant: Self::connection to Error::Transport, Self::timeout to Error::Timeout, Self::protocol to Error::Protocol, Self::redirect to Error::Redirect, Self::request to RequestError::Other, and Self::interrupted to Error::InterruptedBody. Self::from_reqwest reads the class off a reqwest::Error, so super::ReqwestBackend classifies exactly as executing on a reqwest::Client always has. The cause is reachable through std::error::Error::source, and downcasts to its own type there.

Implementations§

Source§

impl TransportError

Source

pub fn connection(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self

A connection-level failure: name resolution, a refused or reset connection, a TLS handshake or certificate error. It becomes Error::Transport, which is transient.

Source

pub fn timeout( kind: TimeoutKind, source: impl Into<Box<dyn Error + Send + Sync>>, ) -> Self

A timeout of the given kind. It becomes Error::Timeout, which is transient; the cause is dropped there, as the variant carries only its TimeoutKind.

Source

pub fn protocol(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self

Malformed HTTP, or a body that could not be decoded (decompression). It becomes Error::Protocol, which is not transient.

Source

pub fn redirect(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self

A redirect the backend’s policy did not follow. It becomes Error::Redirect, which is not transient.

Source

pub fn request(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self

The backend refused the request, or failed inside the send without a connection failure to show for it. It becomes RequestError::Other, which is not transient; that variant’s documentation says why such a request may already have been transmitted.

Source

pub fn interrupted(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self

The connection gave out partway through a body. It becomes Error::InterruptedBody, which is transient; an super::HttpBody whose source fails with an error of any other type reports it as this class.

Source

pub fn from_reqwest(error: Error) -> Self

Classify a reqwest::Error from executing a request into the closest runtime taxonomy class, keeping it as the source. Each class is named below by the Error variant the runtime’s send maps it to.

reqwest reports every failure of the send itself as a request-kind error, a refused connection, an unresolvable host, and a failed TLS handshake included. Those are asked for first (is_connect) and become Error::Transport; only the request-kind errors that are not connection failures stay Error::RequestConstruction. reqwest offers no connect classification on wasm32, where the browser’s fetch reports failures opaquely, so there every request-kind error stays Error::RequestConstruction.

A timeout is asked for before any of those, and the same connect discriminator splits it: one raised while establishing the connection (TransportConfig::connect_timeout, which bounds name resolution, the TCP handshake, and TLS, or the operating system’s own handshake timeout) is TimeoutKind::Connect; every other one, the total-request budget elapsing during the connect included, is TimeoutKind::Total. On wasm32 every timeout is Total, for the reason above.

A builder-kind error is reqwest refusing the request before sending anything, and it becomes Error::RequestConstruction wherever reqwest raises it: from execute on a request it was handed — a URL whose scheme is not http/https, plain http on an https_only client, or a URI that is not a URL. Re-sending it is refused again, so it is not transient.

The query is taken off the URL the error carries, so neither the error’s Display nor its Debug prints an apiKey query credential; the scheme, host and path stay.

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, f: &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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>
where T: Sized,

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self> ⓘ

Get a clone of the Arc<> using a “borrowed” handle. Read more
§

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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