#[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
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:
- Map to
Error::Io
as far as possible. - Map to other
Error
where reasonable. - Fall back on
Error::Other
. - As a last resort
Error::ConnectionFailed
.
ureq does not produce this error using the default connectors.