pub enum Error {
Protocol(Error),
InvalidStatusCodeWithDetails {
status: StatusCode,
body: String,
headers: HeaderMap,
},
InvalidHeaderValue(InvalidHeaderValue),
NoHeaders,
StreamEnded,
InvalidContentType(HeaderValue),
Instance(Box<dyn Error + Send + Sync>),
}Variants§
Protocol(Error)
InvalidStatusCodeWithDetails
Failed HTTP response preserving its status, body, and headers.
Transport failures without a response use Self::Instance or a
protocol variant.
Fields
status: StatusCodeThe non-success status.
InvalidHeaderValue(InvalidHeaderValue)
NoHeaders
StreamEnded
InvalidContentType(HeaderValue)
Instance(Box<dyn Error + Send + Sync>)
target_family=wasm only.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.
The following example reads the seconds form of Retry-After:
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 for a response-less failure: every non-success error
carries its headers.
Source§impl Error
impl Error
Sourcepub fn instance<E>(error: E) -> Error
Available on non-target_family=wasm only.
pub fn instance<E>(error: E) -> Error
target_family=wasm only.Wrap a transport’s native error as Error::Instance. Transports use
this for response-less failures (connect, decode, timeout); non-success
responses go through Error::non_success_with_details instead so the
status stays inspectable.
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
Source§impl From<Error> for VectorStoreError
impl From<Error> for VectorStoreError
Source§impl From<InvalidHeaderValue> for Error
impl From<InvalidHeaderValue> for Error
Source§fn from(source: InvalidHeaderValue) -> Error
fn from(source: InvalidHeaderValue) -> Error
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> 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.