#[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
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
required: SchemeCarrierWhat the scheme carries on the wire.
registered: CredentialKindThe 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.
CredentialProvider
The selected alternative’s token provider returned an error. Raised before anything is
sent; source() is the provider’s AuthError.
Fields
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.
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
impl Debug for RequestError
Source§impl Display for RequestError
impl Display for RequestError
Source§impl Error for RequestError
impl Error for RequestError
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()
Auto Trait Implementations§
impl !RefUnwindSafe for RequestError
impl !UnwindSafe for RequestError
impl Freeze for RequestError
impl Send for RequestError
impl Sync for RequestError
impl Unpin for RequestError
impl UnsafeUnpin for RequestError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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