#[non_exhaustive]pub enum ProviderError {
Api {
status: u16,
code: Option<String>,
message: String,
},
Protocol {
message: String,
},
Decode {
message: String,
},
RateLimited {
retry_after: Option<Duration>,
},
Network(String),
Timeout(TimeoutStage),
Cancelled,
ResponseTooLarge {
limit_bytes: usize,
},
Unsupported {
capability: &'static str,
},
}Expand description
Why a Provider call failed.
The enum categories cover the cases that need distinguishing, with details
carried by fields; vendor-specific errors are mapped into this type at the
implementation boundary. #[non_exhaustive] guarantees that adding new
categories in the future is not a breaking change.
Error classification is the basis for retry decisions (see the Default
judgment of Retryable): Network / Timeout / RateLimited are worth
retrying, while Api is judged by status (5xx retried, 4xx not — retrying
would not change the outcome). Local decode/protocol errors are distinct
from vendor API errors and are not retried by default.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Api
A business/API error returned by the vendor (auth failure / invalid arguments, quota exhaustion, server error), carrying the HTTP status and optional vendor error code.
Fields
Protocol
Provider response was syntactically decoded but violated either the vendor contract or molo’s provider contract.
Decode
Provider response body, SSE frame, or encoded payload could not be decoded.
RateLimited
Rate limited (HTTP 429): retrying is meaningful, and the default retry policy waits before retrying.
retry_after: the wait duration parsed from the vendor’s
Retry-After response header (numeric seconds); None when absent
(HTTP date formats are not parsed).
Fields
Network(String)
A network-layer failure (connection failure and other transport errors).
Implementations map concrete transport errors (e.g. reqwest’s) into carried text, so the error type does not depend on a concrete implementation library’s types.
Timeout(TimeoutStage)
Request timeout, carrying the stage at which it occurred (see
TimeoutStage): distinguishes “cannot connect”, “total duration
elapsed” and “event interval stalled” for easier diagnosis.
Cancelled
Provider request was cancelled through provider context.
ResponseTooLarge
Provider response exceeded a configured local size limit.
Unsupported
Capability was requested from a provider that does not support it.
Trait Implementations§
Source§impl Clone for ProviderError
impl Clone for ProviderError
Source§fn clone(&self) -> ProviderError
fn clone(&self) -> ProviderError
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 ProviderError
impl Debug for ProviderError
Source§impl Display for ProviderError
impl Display for ProviderError
impl Eq 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()