#[non_exhaustive]pub struct HttpError(/* private fields */);Expand description
HTTP transport error reported by the underlying HTTP client.
The inner third-party error type is private; callers diagnose the failure via the accessor methods, all of which return primitive types so this crate can swap or bump the underlying HTTP client without breaking the public API.
Implementations§
Source§impl HttpError
impl HttpError
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
true if the request timed out before a response was received.
Sourcepub fn is_connect(&self) -> bool
pub fn is_connect(&self) -> bool
true if the underlying connection could not be established
(DNS failure, TCP refused, TLS handshake failure, etc.).
Sourcepub fn is_builder(&self) -> bool
pub fn is_builder(&self) -> bool
true if the error originated in the request builder
(URL parse failure, invalid header construction at build time, etc.).
Sourcepub fn is_redirect(&self) -> bool
pub fn is_redirect(&self) -> bool
true if the error is a redirect-loop or too-many-redirects failure.
Sourcepub fn is_request(&self) -> bool
pub fn is_request(&self) -> bool
true if the error happened while sending the request body.
Sourcepub fn is_body(&self) -> bool
pub fn is_body(&self) -> bool
true if the error happened while receiving / decoding the response body.
Sourcepub fn is_decode(&self) -> bool
pub fn is_decode(&self) -> bool
true if the response body could not be decoded as the requested
representation (e.g. JSON parse failure inside the transport layer).
Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
HTTP status code if the error came from a non-success response;
None for transport-level failures (timeout, connection refused, etc.).
Sourcepub fn url(&self) -> Option<String>
pub fn url(&self) -> Option<String>
URL the request was sent to, if known. Returned as an owned String
to avoid leaking the underlying transport’s Url type into this
crate’s public API.
Sourcepub fn kind(&self) -> HttpErrorKind
pub fn kind(&self) -> HttpErrorKind
Classify the error into a single category (bd:JMAP-6r7c.34).
The 8 is_* boolean accessors are
useful when a caller wants to test for a specific category, but
they leave the caller writing a chained-if-else dispatch with
undocumented mutual relationships (“can is_status and
is_decode both be true?”). This method returns a single
HttpErrorKind so a caller can match on it once.
Precedence (highest first) when multiple predicates could
arguably apply: Timeout, Connect, Redirect, Status,
RequestBody, ResponseBody, Decode, Builder, Other.
Status takes precedence over body/decode because reqwest sets
is_status precisely when the failure is “the HTTP server
returned a non-success status code”; in that case the body or
decode flag may also be set, but the most-actionable
classification for a caller is the status code itself.
This method does not return retriability advice — the same
Status(429) may be retriable or fatal depending on the
Retry-After header value, and the same Connect may mean
“DNS not yet warm” (retry) or “host is down” (give up). Make
the retriability decision at the call site, using the kind as
input.
Trait Implementations§
Source§impl Error for HttpError
impl Error for HttpError
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + '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 HttpError
impl !UnwindSafe for HttpError
impl Freeze for HttpError
impl Send for HttpError
impl Sync for HttpError
impl Unpin for HttpError
impl UnsafeUnpin for HttpError
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.