#[non_exhaustive]pub enum Error {
Protocol(Error),
InvalidStatusCodeWithDetails {
status: StatusCode,
body: String,
headers: HeaderMap,
},
StreamEnded,
InvalidContentType(HeaderValue),
Transient(Box<dyn Error + Sync + Send>),
Permanent(Box<dyn Error + Sync + Send>),
}Expand description
Why an HTTP request failed: a protocol or header error, a non-success reply, or the transport’s own error, which says whether sending the same request again may work.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Protocol(Error)
The request could not be built.
InvalidStatusCodeWithDetails
Failed HTTP response preserving its status, body, and headers.
Transport failures without a response use Self::Transient,
Self::Permanent or a protocol variant.
Fields
status: StatusCodeThe non-success status.
StreamEnded
The response stream ended before it was done.
InvalidContentType(HeaderValue)
The response’s content type was not the one expected.
Transient(Box<dyn Error + Sync + Send>)
The transport failed without a reply, and sending the same request again may work: a refused or reset connection, a timeout, a body cut short.
Permanent(Box<dyn Error + Sync + Send>)
The transport failed without a reply, and sending the same request again fails the same way: a request it cannot send as it is, missing credentials, a client that could not be built.
Implementations§
Source§impl Error
impl Error
Sourcepub fn non_success_status(&self) -> Option<StatusCode>
pub fn non_success_status(&self) -> Option<StatusCode>
Preserved HTTP failure status, or None for other error variants.
Sourcepub fn non_success_body(&self) -> Option<&str>
pub fn non_success_body(&self) -> Option<&str>
The response body this error preserved, when it has one. Companion to
Self::non_success_status and Self::non_success_headers.
Sourcepub fn non_success_with_details(
status: StatusCode,
headers: HeaderMap,
body: String,
) -> Error
pub fn non_success_with_details( status: StatusCode, headers: HeaderMap, body: String, ) -> Error
Constructs a failure from its HTTP status, headers, and body without validating that the status is non-successful.
Sourcepub fn non_success_headers(&self) -> Option<&HeaderMap>
pub fn non_success_headers(&self) -> Option<&HeaderMap>
Returns the failed response’s headers, when this error preserved them.
Don’t parse Retry-After from them by hand: a provider error carries
these headers into rig-core’s ErrorReport, whose retry_after reads
every form of the wait a provider asks for.
Returns None for a response-less failure: every non-success error
carries its headers.
Source§impl Error
impl Error
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Whether sending the same request again may pass: after StreamEnded
and what the transport called Error::Transient it may, a status
decides through retryable_status, and after anything else
(protocol, header and content-type errors, Error::Permanent) it
does not. A retry may repeat a request the server already processed.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()
Source§impl From<Error> for ProviderError
impl From<Error> for ProviderError
Auto Trait Implementations§
impl !Freeze for Error
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Forget for Error
impl Move for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.