Skip to main content

HttpError

Enum HttpError 

Source
#[non_exhaustive]
pub enum HttpError { InvalidRequest(String), Transport { message: String, connect_phase: bool, phase: Phase, }, Timeout { message: String, phase: Phase, }, Status { status: u16, body: String, retry_after: Option<Duration>, attempts: u32, }, BodyTooLarge { limit: usize, }, Json(String), Stream(String), Cancelled, SystemProxyUnsupported { element: String, }, AddressDenied { host: String, addr: Option<IpAddr>, class: Option<AddressClass>, reason: String, }, HttpsRequired { host: String, scheme: String, redirect: bool, }, RedirectRefused { host: String, reason: RedirectRefusal, }, }

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InvalidRequest(String)

URL, header, or request construction failed before anything was sent.

§

Transport

Connection, TLS, socket failure, or exhausted redirect limit. connect_phase is true when nothing can have reached the server (safe to retry any method); it is true exactly when phase is Phase::Connect.

Fields

§message: String
§connect_phase: bool
§phase: Phase
§

Timeout

A configured timeout elapsed. message names the elapsed timeout.

Fields

§message: String
§phase: Phase
§

Status

Non-2xx response (after retries were exhausted or not applicable).

Fields

§status: u16
§body: String
§retry_after: Option<Duration>
§attempts: u32
§

BodyTooLarge

Response body exceeded the configured limit.

Fields

§limit: usize
§

Json(String)

Response was not valid JSON for the requested type.

§

Stream(String)

Streaming protocol violation (oversized SSE line, bad UTF-8, …).

§

Cancelled

The call was cancelled through a crate::CancelToken.

§

SystemProxyUnsupported

ProxyMode::System: the Windows proxy settings hold something this version cannot follow exactly, named in element: different proxy routes for HTTP and HTTPS, a bypass entry that is not a plain host (<local>, an entry limited to one scheme, an inner wildcard), or a proxy auto-config script. The client sends nothing: it never drops a bypass entry while still using the proxy, and never sends one scheme to the other’s proxy. “Automatically detect settings” alone is not refused (since 0.3.1; see ProxyModeUsed). Returned by Client::try_new and by every request of a client built with Client::new. An app catches it and uses the mode it used before (ProxyMode::Environment, or ProxyMode::Explicit). Never retried.

Fields

§element: String
§

AddressDenied

The outbound address policy refused the destination (see crate::netpolicy). addr and class are None when the denial is about the name or scheme (no address, a metadata host name, or a host outside a first-party list). reason carries the detail, including custom deny_if text. Never retried.

Fields

§host: String
§reason: String
§

HttpsRequired

crate::ClientConfig::https_only is set and the URL (or a redirect target when redirect is true) is not https. scheme is lowercase, host has no credentials. Nothing was sent to that URL. Never retried.

Fields

§host: String
§scheme: String
§redirect: bool
§

RedirectRefused

A redirect target was refused before anything was sent to it: its origin is outside the request’s crate::ApprovedOrigins, or its URL carries userinfo or an unsafe shape (see RedirectRefusal). host is the target’s host, without userinfo, path or query. The earlier hops were sent. Never retried, since the same redirect would be refused again.

Fields

§host: String

Implementations§

Source§

impl HttpError

Source

pub fn phase(&self) -> Option<Phase>

The Phase of a Timeout or Transport error; None for every other kind.

Source

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

Source

pub fn class(&self) -> ErrorClass

The error’s ErrorClass. See the README for the full table.

Trait Implementations§

Source§

impl Debug for HttpError

Source§

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

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

impl Display for HttpError

Source§

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

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

impl Error for HttpError

1.30.0 · 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<AddressDenial> for HttpError

Source§

fn from(d: AddressDenial) -> Self

Converts to this type from the input type.

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.

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.