#[non_exhaustive]pub enum ProviderErrorKind {
Show 18 variants
Timeout,
RateLimited {
retry_after: Option<Duration>,
},
Authentication,
Authorization,
CredentialExpired,
QuotaExhausted {
scope: Option<ErrorCode>,
},
InvalidRequest,
ContextOverflow {
needed_tokens: Option<u64>,
limit_tokens: Option<u64>,
},
ModelNotFound,
Refusal,
ContentFilter,
Malformed,
Transport,
Server {
status: Option<u16>,
},
Cancelled,
CapabilityMismatch {
mismatch: CapabilityMismatch,
},
Unsupported {
feature: ErrorCode,
},
Other,
}Expand description
The failure families an adapter maps its vendor errors into.
Growable: match with a _ arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Timeout
The call exceeded ModelRequest::timeout
or the transport deadline. The model call itself has no effect, so a
timeout here is safe to retry before commit.
RateLimited
The provider rate-limited the request.
Authentication
The credentials were rejected as invalid — a wrong or revoked key.
A key that was valid and has expired is
CredentialExpired instead, because the two
call for opposite reactions.
Authorization
The credentials are valid but not entitled to this model or endpoint.
CredentialExpired
A credential that was valid has expired.
Deliberately not Authentication. A wrong key
stays wrong; an expired one becomes valid again the moment it is
refreshed, and several providers issue short-lived credentials as a
matter of design — Vertex AI bearer tokens and Bedrock session
credentials both expire on a schedule. Folding the two together forces
one of two wrong behaviours: a caller that could refresh and continue
gives up, or a caller that cannot refresh retries a credential that
will never work again.
Its class is Fallback, which reads as “not
with this credential as it stands”. A caller holding a refresher may
refresh and retry the same profile; a caller without one must treat
it as fatal for that profile and move on. It is never
Retry: retrying the same expired token is a busy
loop.
QuotaExhausted
The account’s quota or credit balance is exhausted.
Deliberately not RateLimited, even when the
provider reports it with HTTP 429, which several do. A rate limit
means “wait and it will work”; an exhausted quota or an empty credit
balance means it will not work until a window resets or a human tops the
account up — hours or days, not seconds. Sleeping on it burns the turn’s
deadline for nothing, which is why its class is
Fallback: the router moves to another
candidate instead of waiting.
Fields
InvalidRequest
The provider rejected the request as malformed. Our request is wrong; another provider will reject it too.
ContextOverflow
The prompt exceeded the model’s context window.
Fields
ModelNotFound
The configured model does not exist at this provider.
Refusal
The model declined to answer. A semantic outcome, not a transport fault.
ContentFilter
The provider’s safety filter blocked the prompt or the completion.
Malformed
The response could not be normalized: unparseable body, a tool-call fragment that is not JSON, a stream that ended without a finish event.
Transport
The request never got a complete answer from the network.
Server
The provider returned a server-side error.
Cancelled
The caller cancelled the call.
CapabilityMismatch
The provider-model pair does not satisfy the requirements of the stage (spec §0 rule 9). Never resolved by weakening the requirements.
Fields
mismatch: CapabilityMismatchExactly which requirements were unmet.
Unsupported
The adapter cannot serve a feature the request asked for (streaming, a content part, a tool-choice mode).
Other
Anything the adapter could not place. Fails closed.
Implementations§
Source§impl ProviderErrorKind
impl ProviderErrorKind
Sourcepub const fn as_str(&self) -> &'static str
pub const fn as_str(&self) -> &'static str
Stable snake-case label for metrics, replay records and reports.
Sourcepub const fn retry_after(&self) -> Option<Duration>
pub const fn retry_after(&self) -> Option<Duration>
The delay the provider asked for, when this kind carries one.
Sourcepub const fn retry_class(&self) -> RetryClass
pub const fn retry_class(&self) -> RetryClass
How the caller may proceed.
The reasoning behind the less obvious rows:
ContextOverflowisFatal: the same prompt is too long for the candidate that was already judged large enough, so the runtime must shrink the context rather than shop for a bigger window mid-flight.RefusalandContentFilterareFatal: retrying elsewhere until a model complies is a safety bypass, not a recovery.Authentication,AuthorizationandModelNotFoundareFallback: they are configuration faults of one profile, and another candidate may be configured correctly.CredentialExpiredisFallbackrather thanRetry: the same credential will keep failing until something outside this call refreshes it. A caller that owns a refresher may refresh and call the same profile again; a caller that does not must treat it as fatal for that profile.QuotaExhaustedisFallbackand neverRetryAfter, whatever status it arrived on: waiting does not refill a quota.CapabilityMismatchisFallbackbecause the router only ever offers candidates that satisfy the same requirements; moving on is not a downgrade.MalformedisRetry: a re-roll of the same request is the standard remedy for a decode that went off the rails.
Sourcepub const fn core_code(&self) -> ProviderFailureCode
pub const fn core_code(&self) -> ProviderFailureCode
Maps onto the normalized code the core error family stores.
Trait Implementations§
Source§impl Clone for ProviderErrorKind
impl Clone for ProviderErrorKind
Source§impl Debug for ProviderErrorKind
impl Debug for ProviderErrorKind
Source§impl<'de> Deserialize<'de> for ProviderErrorKind
impl<'de> Deserialize<'de> for ProviderErrorKind
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ProviderErrorKind
impl Display for ProviderErrorKind
impl Eq for ProviderErrorKind
Source§impl PartialEq for ProviderErrorKind
impl PartialEq for ProviderErrorKind
Source§impl Serialize for ProviderErrorKind
impl Serialize for ProviderErrorKind
impl StructuralPartialEq for ProviderErrorKind
Auto Trait Implementations§
impl Freeze for ProviderErrorKind
impl RefUnwindSafe for ProviderErrorKind
impl Send for ProviderErrorKind
impl Sync for ProviderErrorKind
impl Unpin for ProviderErrorKind
impl UnsafeUnpin for ProviderErrorKind
impl UnwindSafe for ProviderErrorKind
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.