pub struct ProviderResponseError {
pub status: Option<StatusCode>,
pub body: String,
pub provider_request_id: Option<String>,
pub headers: Option<Box<HeaderMap>>,
}Expand description
A raw error response preserved from a provider.
Capability errors store this in their ProviderResponse variants when Rig
has the provider’s response body in hand. Unlike ProviderError(String),
which may carry Rig-generated diagnostics, this type always represents the
payload the provider actually returned.
Prefer Self::new / Self::without_status and the with_* setters
over a struct literal: a literal has to be revisited every time transport
metadata grows, and the constructors do not.
Fields§
§status: Option<StatusCode>HTTP status of the provider response, when it was captured alongside the body.
body: StringRaw response body as returned by the provider.
provider_request_id: Option<String>The provider’s transport request id for the failed call (HTTP response
header such as Anthropic request-id / OpenAI x-request-id, or SDK
response metadata) — the id provider support asks for when
investigating a request, which matters most on exactly these failed
calls. None means the provider did not report one — a documented
outcome, never a secondary error (rig#2314).
headers: Option<Box<HeaderMap>>The response’s headers, verbatim, when the capture path had them in
hand — the rate-limit metadata (Retry-After, x-ratelimit-*) a
caller needs to back off correctly after a 429 (rig#2210). Boxed to
keep this error small enough for clippy::result_large_err. None
means “not captured”, never “the response had no headers”.
Implementations§
Source§impl ProviderResponseError
impl ProviderResponseError
Sourcepub fn new(status: StatusCode, body: impl Into<String>) -> Self
pub fn new(status: StatusCode, body: impl Into<String>) -> Self
Preserve a provider error response captured with its HTTP status.
Sourcepub fn without_status(body: impl Into<String>) -> Self
pub fn without_status(body: impl Into<String>) -> Self
Preserve a provider error body that has no HTTP status (gRPC / SDK transports).
Sourcepub fn with_provider_request_id(self, request_id: Option<String>) -> Self
pub fn with_provider_request_id(self, request_id: Option<String>) -> Self
Attach the transport request id the failed response reported.
Sourcepub fn with_headers(self, headers: Option<Box<HeaderMap>>) -> Self
pub fn with_headers(self, headers: Option<Box<HeaderMap>>) -> Self
Attach the response’s headers, so rate-limit metadata survives onto the error (rig#2210).
Trait Implementations§
Source§impl Clone for ProviderResponseError
impl Clone for ProviderResponseError
Source§fn clone(&self) -> ProviderResponseError
fn clone(&self) -> ProviderResponseError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProviderResponseError
impl Debug for ProviderResponseError
Source§impl Display for ProviderResponseError
impl Display for ProviderResponseError
impl Eq for ProviderResponseError
Source§impl Error for ProviderResponseError
impl Error for ProviderResponseError
1.30.0 · 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 PartialEq for ProviderResponseError
impl PartialEq for ProviderResponseError
impl StructuralPartialEq for ProviderResponseError
Auto Trait Implementations§
impl Freeze for ProviderResponseError
impl RefUnwindSafe for ProviderResponseError
impl Send for ProviderResponseError
impl Sync for ProviderResponseError
impl Unpin for ProviderResponseError
impl UnsafeUnpin for ProviderResponseError
impl UnwindSafe for ProviderResponseError
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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.