pub enum ProviderError {
Api(String),
Network(String),
Auth(String),
RateLimited {
retry_after_ms: Option<u64>,
},
ContextOverflow {
message: String,
},
Cancelled,
Other(String),
SchemaMismatch {
reason: String,
},
}Variants§
Api(String)
A non-transient API error (bad request, server error, etc.).
Network(String)
Network/transport failure — connection refused, timeout, TLS error, etc.
Auth(String)
Authentication failure — bad or missing API key (HTTP 401/403).
RateLimited
Rate limit hit (HTTP 429). retry_after_ms is the server-specified delay if present.
ContextOverflow
Input exceeds the model’s context window. Caller should compact and retry.
Cancelled
The caller cancelled the request via CancellationToken.
Other(String)
Catch-all for errors that don’t fit another category.
SchemaMismatch
Returned by structured-output paths when the requested ResponseFormat is
unsupported by the provider, or when extracting JSON from a response fails
(Message::extract_json::<T>() returns this on parse / deserialise errors).
Implementations§
Source§impl ProviderError
impl ProviderError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether this error is safe to retry.
Retryable: rate limits (429) and network/transient errors. Not retryable: auth errors, API errors (bad request), cancellation.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
If this is a rate limit with a server-specified retry delay, return it.
Source§impl ProviderError
impl ProviderError
Sourcepub fn classify(status: u16, message: &str) -> Self
pub fn classify(status: u16, message: &str) -> Self
Classify an HTTP error response into the appropriate error variant.
Detects context overflow, rate limits, auth errors, and general API errors from the HTTP status code and response body.
Sourcepub fn is_context_overflow(&self) -> bool
pub fn is_context_overflow(&self) -> bool
Returns true if this error indicates a context overflow.
Trait Implementations§
Source§impl Debug for ProviderError
impl Debug for ProviderError
Source§impl Display for ProviderError
impl Display for ProviderError
Source§impl Error for ProviderError
impl Error for ProviderError
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()
Auto Trait Implementations§
impl Freeze for ProviderError
impl RefUnwindSafe for ProviderError
impl Send for ProviderError
impl Sync for ProviderError
impl Unpin for ProviderError
impl UnsafeUnpin for ProviderError
impl UnwindSafe for ProviderError
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
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt 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.