Enum Error

Source
#[non_exhaustive]
pub enum Error {
Show 28 variants StatusCode(u16), Http(Error), BadUri(String), Protocol(Error), Io(Error), Timeout(Timeout), HostNotFound, RedirectFailed, InvalidProxyUrl, ConnectionFailed, BodyExceedsLimit(u64), TooManyRedirects, Tls(&'static str), Pem(Error), Rustls(Error), NativeTls(Error), Der(Error), Cookie(CookieError), CookieValue(&'static str), CookieJar(Error), UnknownCharset(String), RequireHttpsOnly(String), LargeResponseHeader(usize, usize), Decompress(&'static str, Error), Json(Error), ConnectProxyFailed(String), TlsRequired, Other(Box<dyn Error + Send + Sync>),
}
Expand description

Errors from ureq.

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

StatusCode(u16)

When http_status_as_error() is true, 4xx and 5xx response status codes are translated to this error.

This is the default behavior.

§

Http(Error)

Errors arising from the http-crate.

These errors happen for things like invalid characters in header names.

§

BadUri(String)

Error if the URI is missing scheme or host.

§

Protocol(Error)

An HTTP/1.1 protocol error.

This can happen if the remote server ends incorrect HTTP data like missing version or invalid chunked transfer.

§

Io(Error)

Error in io such as the TCP socket.

§

Timeout(Timeout)

Error raised if the request hits any configured timeout.

By default no timeouts are set, which means this error can’t happen.

§

HostNotFound

Error when resolving a hostname fails.

§

RedirectFailed

A redirect failed.

This happens when ureq encounters a redirect when sending a request body such as a POST request, and receives a 307/308 response. ureq refuses to redirect the POST body and instead raises this error.

§

InvalidProxyUrl

Error when creating proxy settings.

§

ConnectionFailed

A connection failed.

This is a fallback error when there is no other explanation as to why a connector chain didn’t produce a connection. The idea is that the connector chain would return some other Error rather than rely om this value.

Typically bespoke connector chains should, as far as possible, map their underlying errors to Error::Io and use the io::ErrorKind to provide a reason.

A bespoke chain is allowed to map to this value, but that provides very little information to the user as to why the connection failed. One way to mitigate that would be to rely on the log crate to provide additional information.

§

BodyExceedsLimit(u64)

A send body (Such as &str) is larger than the content-length header.

§

TooManyRedirects

Too many redirects.

The error can be turned off by setting max_redirects_will_error() to false. When turned off, the last response will be returned instead of causing an error, even if it is a redirect.

The number of redirects is limited to 10 by default.

§

Tls(&'static str)

Some error with TLS.

§

Pem(Error)

Error in reading PEM certificates/private keys.

Note: The wrapped error struct is not considered part of ureq API. Breaking changes in that struct will not be reflected in ureq major versions.

§

Rustls(Error)

An error originating in Rustls.

Note: The wrapped error struct is not considered part of ureq API. Breaking changes in that struct will not be reflected in ureq major versions.

§

NativeTls(Error)

An error originating in Native-TLS.

Note: The wrapped error struct is not considered part of ureq API. Breaking changes in that struct will not be reflected in ureq major versions.

§

Der(Error)

An error providing DER encoded certificates or private keys to Native-TLS.

Note: The wrapped error struct is not considered part of ureq API. Breaking changes in that struct will not be reflected in ureq major versions.

§

Cookie(CookieError)

An error with the cookies.

Note: The wrapped error struct is not considered part of ureq API. Breaking changes in that struct will not be reflected in ureq major versions.

§

CookieValue(&'static str)

An error parsing a cookie value.

§

CookieJar(Error)

An error in the cookie store.

Note: The wrapped error struct is not considered part of ureq API. Breaking changes in that struct will not be reflected in ureq major versions.

§

UnknownCharset(String)

An unrecognised character set.

§

RequireHttpsOnly(String)

The setting https_only is true and the URI is not https.

§

LargeResponseHeader(usize, usize)

The response header, from status up until body, is too big.

§

Decompress(&'static str, Error)

Body decompression failed (gzip or brotli).

§

Json(Error)

Serde JSON error.

§

ConnectProxyFailed(String)

Attempt to connect to a CONNECT proxy failed.

§

TlsRequired

The protocol requires TLS (https), but the connector did not create a TLS secured transport.

This typically indicates a fault in bespoke Connector chains.

§

Other(Box<dyn Error + Send + Sync>)

Some other error occured.

This is an escape hatch for bespoke connector chains having errors that don’t naturally map to any other error. For connector chains we recommend:

  1. Map to Error::Io as far as possible.
  2. Map to other Error where reasonable.
  3. Fall back on Error::Other.
  4. As a last resort Error::ConnectionFailed.

ureq does not produce this error using the default connectors.

Implementations§

Source§

impl Error

Source

pub fn into_io(self) -> Error

Convert the error into a std::io::Error.

If the error is Error::Io, we unpack the error. In othe cases we make an std::io::ErrorKind::Other.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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<Box<dyn Error + Send + Sync>> for Error

Source§

fn from(value: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(value: CookieError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(value: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(value: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(value: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(value: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(value: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(value: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

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

impl<T> ErasedDestructor for T
where T: 'static,