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
impl TransportError
Sourcepub fn connection(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
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.
Sourcepub fn timeout(
kind: TimeoutKind,
source: impl Into<Box<dyn Error + Send + Sync>>,
) -> Self
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.
Sourcepub fn protocol(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
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.
Sourcepub fn redirect(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
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.
Sourcepub fn request(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
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.
Sourcepub fn interrupted(source: impl Into<Box<dyn Error + Send + Sync>>) -> Self
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.
Sourcepub fn from_reqwest(error: Error) -> Self
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
impl Debug for TransportError
Source§impl Display for TransportError
impl Display for TransportError
Source§impl Error for TransportError
impl Error for TransportError
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()
Auto Trait Implementations§
impl !RefUnwindSafe for TransportError
impl !UnwindSafe for TransportError
impl Freeze for TransportError
impl Send for TransportError
impl Sync for TransportError
impl Unpin for TransportError
impl UnsafeUnpin for TransportError
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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