#[non_exhaustive]pub enum Error {
Fetch(String),
HttpStatus {
status: u16,
url: String,
response: Option<Box<ErrorResponse>>,
},
RedirectLimit {
url: String,
hops: u32,
},
FetchTooLarge {
limit: u64,
},
ContentEncoded {
url: String,
encoding: String,
},
Unsupported(String),
UploadInterrupted {
url: String,
message: String,
},
}Expand description
The error of each fallible operation of this crate.
A caller outside this crate can build each variant. Each variant converts
to the ostrya::Error variant of the same name, with the same message.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Fetch(String)
A failure to set up or to carry out a request.
The causes include an option value, a mirror URL, a header, or a TLS
configuration that the fetcher cannot use. They also include a refused
credential, a refused redirect hop, an error of the request signer, and
a transport failure or an expired deadline that outlived the retries.
Fetcher::fetch and
Fetcher::upload list the cases.
HttpStatus
An HTTP status other than 200 and 304 that ended a fetch.
A 404 means that the remote does not hold the requested file. The statuses 408, 429, and 5xx are retryable, and each other status is definitive. If a fetch fails, it reports the first definitive failure that it received, from any round. If it received no definitive failure, it reports the first retryable failure.
If the reported failure is a status, it is this variant.
Fetcher::fetch states the failure order. An
upload returns each status in an Uploaded and does
not fail with this variant.
A fetch that sets
max_error_body gets the
headers and the body of the reported response in response.
Fields
response: Option<Box<ErrorResponse>>The headers and the capped body of the response, if
FetchRequest::max_error_body
asked for them. None otherwise.
RedirectLimit
A redirect chain that reached the limit of
max_redirects.
The response at the end of the chain named another URL to follow. Each attempt against one destination counts its own hops, so a repeated round counts again from the destination that the route named.
Fields
FetchTooLarge
A response that declared more bytes than the cap of the caller.
If a body grows past the cap while it streams, the read fails with the
FileTooLarge kind. The payload of
that I/O error is a message string. It does not downcast to Error.
ContentEncoded
A response that declared a coding in Content-Encoding or
Transfer-Encoding.
The body of such a response holds bytes other than the bytes that the
remote stores. The value identity in each header and the value
chunked in Transfer-Encoding declare no coding.
Unsupported(String)
A URL or a proxy variable that the fetcher cannot use.
The causes are a proxy URL or a proxy variable that the fetcher cannot
carry. A request URL whose scheme is not http or https is also a
cause.
Proxy states the rules of the proxy URL and of the
proxy variables.
UploadInterrupted
An upload that failed after hyper took its request.
The causes are:
- The connection failed while the request or the response head was in transit.
- The writer of the body was dropped, or a frame of the body waited past the stall window.
- No response head arrived within the response window.
- The response head is one that the upload does not deliver. Such a head names a redirect that the upload cannot follow, or is a 2xx head that declares a coding or a length over the cap. An answer other than 2xx with such a body keeps its status, and the upload withholds the body.
The server can have received the whole request and acted on it, so the outcome is unknown. The fetcher does not send the request again.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_unsent(&self) -> bool
pub fn is_unsent(&self) -> bool
Returns true if an upload failed before it handed its request over.
The hand-over gives the request to hyper. No byte of a request reaches a server before the hand-over, so the server does nothing for it.
Each failure of an upload after the hand-over is
Error::UploadInterrupted, whatever ended it. The method returns
false for that variant. It returns true for each other error of an
upload. Examples are a refusal before admission, a failed connect or
handshake, and rounds that ran out before the request was sent.
The answer applies only to the errors of
Fetcher::upload. A fetch never fails with
UploadInterrupted, and it can fail with any other variant after it
sent its request.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · 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()