Skip to main content

RequestError

Enum RequestError 

Source
#[non_exhaustive]
pub enum RequestError { MissingCredential { alternatives: Vec<Vec<&'static str>>, }, CredentialMismatch { scheme: &'static str, required: SchemeCarrier, registered: CredentialKind, }, InvalidBasicUsername { scheme: &'static str, }, CredentialProvider { scheme: &'static str, source: AuthError, }, MissingBoundParameter { name: &'static str, }, Other(RequestCause), }
Expand description

Request-construction failure (taxonomy #1).

The four credential causes are the ones a consumer routes on — they mean “unauthenticated”, not “malformed request” — so each is a variant of its own: RequestError::MissingCredential when no registered credential satisfies the requirement, RequestError::CredentialMismatch when the selected alternative has a credential registered that its scheme cannot carry, RequestError::InvalidBasicUsername when its http basic credential’s username holds :, and RequestError::CredentialProvider when a registered token provider fails. All four are raised before anything is sent, and so is RequestError::MissingBoundParameter, when an operation declares a required header the client binds and no value is bound to it. Every other cause arrives as RequestError::Other with its source attached — and RequestError::Other is not uniformly pre-send; see its own documentation before retrying on it.

This runtime is embedded in the consumer’s own crate, where #[non_exhaustive] does not affect match exhaustiveness, so a new variant here is a breaking change of the generated output; the attribute is kept for a consumer that re-exports the generated module across a crate boundary.

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

MissingCredential

The operation carries a security requirement and no registered credential satisfies any of its non-empty alternatives, and either it lists no empty {} alternative or a credential is registered for one of its schemes (a partial registration, which {} does not absorb). Raised before anything is sent. The payload is the whole cause, so source() is None.

Fields

§alternatives: Vec<Vec<&'static str>>

One entry per non-empty alternative of the requirement (an empty {} alternative has nothing to report), in declaration order: that alternative’s securitySchemes keys that have no registered credential, in declaration order. mutualTLS keys never appear (the transport satisfies them).

The runtime never builds an empty outer list, nor an empty inner one — it only reaches this variant with at least one unregistered scheme per alternative. The field is public inside the consumer’s crate, though, so the invariant is not enforced by the type; Display therefore omits the (missing: …) clause entirely rather than rendering an empty one, and skips an empty alternative when listing.

§

CredentialMismatch

The selected alternative has a credential registered under one of its schemes, but of a kind that scheme cannot carry — a Credential::Basic under a bearer or apiKey scheme, or anything but Credential::Basic under an http basic one. Raised before anything is sent, and before a registered token provider is asked for a token. The payload is the whole cause, so source() is None.

The registration is what needs correcting: attaching credentials never falls through to a later alternative.

Fields

§scheme: &'static str

The securitySchemes key the credential is registered under.

§required: SchemeCarrier

What the scheme carries on the wire.

§registered: CredentialKind

The Credential variant registered under scheme.

§

InvalidBasicUsername

The selected alternative has a Credential::Basic registered under an http basic scheme whose username holds :, which RFC 7617 §2 forbids: the server splits the decoded credentials at their first colon, so it would read another user and password. Raised before anything is sent. The payload is the whole cause, so source() is None.

The registration is what needs correcting: attaching credentials never falls through to a later alternative.

Fields

§scheme: &'static str

The securitySchemes key the credential is registered under.

§

CredentialProvider

The selected alternative’s token provider returned an error. Raised before anything is sent; source() is the provider’s AuthError.

Fields

§scheme: &'static str

The securitySchemes key the provider is registered under.

§source: AuthError

What the provider reported.

§

MissingBoundParameter

The operation declares a required header that the generated client binds once, as a Spec::add_bound_header build option named it, and no value is bound to it on the client (with_bound_header). Raised before anything is sent. The payload is the whole cause, so source() is None.

Fields

§name: &'static str

The header’s name, as the operation declares it.

§

Other(RequestCause)

Any other request-construction failure, with the cause reachable through source().

Pre-send, raised before anything is transmitted: an unparseable base URL; a parameter, body, or credential value that did not serialize; or reqwest refusing the request when asked to send it (a builder-kind error), as it does for a URL scheme other than http/https or plain http on an https_only client.

Not pre-send: an error reqwest classifies as a request error. reqwest raises that class from inside the send, so the request may already have been transmitted and the server may already have acted on it. This variant is therefore the one place in taxonomy #1 where “the request was never sent” does not hold, and a caller that retries on it must treat the call as possibly-already-applied. A connection that was never established is classified apart, as TransportError::from_reqwest describes.

After a response was accepted: when the API has streaming (sequential) responses, the embedded EventStream raises this when the stored request cannot be cloned for an automatic reconnect — from with_reconnect, and from poll_next once the reconnect wait has elapsed, mid-stream, after frames may already have been yielded. Nothing was transmitted for the reconnect itself, so the possibly-already-applied reading above does not describe it; re-driving the operation from the start re-delivers events the caller has already consumed instead.

Trait Implementations§

Source§

impl Debug for RequestError

Source§

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

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

impl Display for RequestError

Source§

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

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

impl Error for RequestError

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

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>
where T: Sized,

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self> ⓘ

Get a clone of the Arc<> using a “borrowed” handle. Read more
§

impl<T> Instrument for T

§

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

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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