Skip to main content

Error

Enum Error 

Source
#[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
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.
§

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

§status: u16

The status of the response.

§url: String

The URL of the hop that answered with the status.

§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

§url: String

The URL of the last hop, whose Location the limit did not follow.

§hops: u32

The number of redirects that the attempt followed, which is the limit.

§

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.

Fields

§limit: u64

The cap that the caller set on the request.

§

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.

Fields

§url: String

The URL that answered.

§encoding: String

The coding that the response declared.

§

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.

Fields

§url: String

The URL that the request was sent to.

§message: String

The text that names what ended the upload.

Implementations§

Source§

impl Error

Source

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 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, __formatter: &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

Replaced by Error::source.
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

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more