pub struct ProviderResponseError {
pub status: Option<StatusCode>,
pub body: String,
pub provider_request_id: Option<String>,
pub headers: Option<HeaderMap>,
pub code: Option<String>,
pub transient: Option<bool>,
pub refusal: bool,
pub route: Option<String>,
}Expand description
A raw provider error body with captured transport metadata.
Callers must supply the provider’s actual payload, not a generated diagnostic.
Serialization omits headers and route; deserialization restores them as None.
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>Transport request ID from response headers or SDK metadata, when captured.
headers: Option<HeaderMap>Captured response headers, including rate-limit metadata. None means
not captured, rather than an empty header set. Omitted during serialization.
code: Option<String>The provider’s own machine-readable code for the failure, when the
transport reported one apart from the body: a gRPC status code name
(UNAVAILABLE), an AWS exception type (ThrottlingException).
None when the reply carried only a status and a body.
transient: Option<bool>Transport retry verdict used when status is absent or successful. A non-success HTTP status takes precedence; refusals are never retryable.
refusal: boolWhether this error represents a content refusal. Refusals are never retryable; refusal content in a successful model answer is separate.
route: Option<String>The provider and request path the reply answered, when the operation records them for diagnostics (model listing does). Omitted during serialization.
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_refusal(self, refusal: bool) -> Self
pub fn with_refusal(self, refusal: bool) -> Self
Mark the reply as the provider’s verdict on the content: a refusal, final, never retried.
Sourcepub fn with_status(self, status: Option<StatusCode>) -> Self
pub fn with_status(self, status: Option<StatusCode>) -> Self
Attach the HTTP status a transport reported beside a reply that was first preserved without one (an SDK that hands back the raw HTTP response next to its typed exception). A status already set is kept.
Sourcepub fn with_code(self, code: Option<String>) -> Self
pub fn with_code(self, code: Option<String>) -> Self
Attach the provider’s own machine-readable code for the failure.
Sourcepub fn with_transient(self, transient: Option<bool>) -> Self
pub fn with_transient(self, transient: Option<bool>) -> Self
Replaces the transport retry verdict. Used for absent or successful HTTP statuses unless the response is a refusal.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns false for refusals. Otherwise classifies non-success HTTP statuses
through crate::error::retryable_status, or uses transient for absent
or successful statuses. Missing verdicts default to false.
Sourcepub fn machine_code(&self) -> Option<String>
pub fn machine_code(&self) -> Option<String>
Returns the explicit code, falling back to nonempty string fields
error.code, error.status, then error.type in the JSON body.
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<HeaderMap>) -> Self
pub fn with_headers(self, headers: Option<HeaderMap>) -> Self
Replaces captured response headers, including rate-limit metadata.
Trait Implementations§
Source§impl Clone for ProviderResponseError
impl Clone for ProviderResponseError
Source§impl Debug for ProviderResponseError
impl Debug for ProviderResponseError
Source§impl<'de> Deserialize<'de> for ProviderResponseError
impl<'de> Deserialize<'de> for ProviderResponseError
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
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
Source§impl Serialize for ProviderResponseError
impl Serialize 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> 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> IntoToolOutput for Twhere
T: Serialize + 'static,
impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
Source§fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
Source§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.