pub enum Error {
Protocol(Error),
InvalidStatusCode(StatusCode),
InvalidStatusCodeWithMessage(StatusCode, String),
InvalidStatusCodeWithDetails {
status: StatusCode,
body: String,
headers: Box<HeaderMap>,
},
InvalidHeaderValue(InvalidHeaderValue),
NoHeaders,
StreamEnded,
InvalidContentType(HeaderValue),
Instance(Box<dyn Error + Send + Sync + 'static>),
}Variants§
Protocol(Error)
InvalidStatusCode(StatusCode)
InvalidStatusCodeWithMessage(StatusCode, String)
InvalidStatusCodeWithDetails
A non-success HTTP response whose headers were preserved alongside the
body, so provider layers can read transport metadata — e.g. their
request-id contract — off the failed response (rig#2314). Displays
identically to Self::InvalidStatusCodeWithMessage.
Fields
status: StatusCodeThe non-success status.
InvalidHeaderValue(InvalidHeaderValue)
NoHeaders
StreamEnded
InvalidContentType(HeaderValue)
Instance(Box<dyn Error + Send + Sync + 'static>)
target_family=wasm only.Implementations§
Source§impl Error
impl Error
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.
Rig’s bundled HTTP clients capture the full HeaderMap whenever a
non-success status error is built from a live response, so rate-limit
metadata such as Retry-After or x-ratelimit-* stays readable
(rig#2210). This is the accessor a retry::RetryPolicy uses to honor
a server-supplied backoff, since it is handed this error directly:
fn retry_after(error: &Error) -> Option<Duration> {
let seconds = error
.non_success_headers()?
.get(http::header::RETRY_AFTER)?
.to_str()
.ok()?
.parse()
.ok()?;
Some(Duration::from_secs(seconds))
}Returns None when the error carries no captured headers: transports
that report a non-success status without them, and errors built from
only a status and body.
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 AudioGenerationError
Available on crate feature audio only.
impl From<Error> for AudioGenerationError
audio only.Source§impl From<Error> for VerifyError
impl From<Error> for VerifyError
Source§impl From<Error> for ProviderClientError
impl From<Error> for ProviderClientError
Source§impl From<Error> for CompletionError
impl From<Error> for CompletionError
Source§impl From<Error> for EmbeddingError
impl From<Error> for EmbeddingError
Source§impl From<Error> for ImageGenerationError
Available on crate feature image only.
impl From<Error> for ImageGenerationError
image only.Source§impl From<Error> for ModelListingError
impl From<Error> for ModelListingError
Source§impl From<Error> for RerankError
impl From<Error> for RerankError
Source§impl From<Error> for TranscriptionError
impl From<Error> for TranscriptionError
Source§impl From<InvalidHeaderValue> for Error
impl From<InvalidHeaderValue> for Error
Source§fn from(source: InvalidHeaderValue) -> Self
fn from(source: InvalidHeaderValue) -> Self
Auto Trait Implementations§
impl !Freeze for Error
impl !RefUnwindSafe for Error
impl !UnwindSafe 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> 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.