Skip to main content

ProviderErrorKind

Enum ProviderErrorKind 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

Fields

§retry_after: Option<Duration>

The delay the provider asked for, when it supplied one.

§

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

§scope: Option<ErrorCode>

The quota the provider named, when it named one, as a short sanitized code: "tokens_per_day", "credit_balance".

§

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

§needed_tokens: Option<u64>

Tokens the provider says the request needed, when reported.

§limit_tokens: Option<u64>

The model’s limit, when reported.

§

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.

Fields

§status: Option<u16>

HTTP status, when there was one.

§

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: CapabilityMismatch

Exactly which requirements were unmet.

§

Unsupported

The adapter cannot serve a feature the request asked for (streaming, a content part, a tool-choice mode).

Fields

§feature: ErrorCode

Name of the feature, e.g. "streaming".

§

Other

Anything the adapter could not place. Fails closed.

Implementations§

Source§

impl ProviderErrorKind

Source

pub const fn as_str(&self) -> &'static str

Stable snake-case label for metrics, replay records and reports.

Source

pub const fn retry_after(&self) -> Option<Duration>

The delay the provider asked for, when this kind carries one.

Source

pub const fn retry_class(&self) -> RetryClass

How the caller may proceed.

The reasoning behind the less obvious rows:

  • ContextOverflow is Fatal: 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.
  • Refusal and ContentFilter are Fatal: retrying elsewhere until a model complies is a safety bypass, not a recovery.
  • Authentication, Authorization and ModelNotFound are Fallback: they are configuration faults of one profile, and another candidate may be configured correctly.
  • CredentialExpired is Fallback rather than Retry: 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.
  • QuotaExhausted is Fallback and never RetryAfter, whatever status it arrived on: waiting does not refill a quota.
  • CapabilityMismatch is Fallback because the router only ever offers candidates that satisfy the same requirements; moving on is not a downgrade.
  • Malformed is Retry: a re-roll of the same request is the standard remedy for a decode that went off the rails.
Source

pub const fn core_code(&self) -> ProviderFailureCode

Maps onto the normalized code the core error family stores.

Trait Implementations§

Source§

impl Clone for ProviderErrorKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProviderErrorKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ProviderErrorKind

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ProviderErrorKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ProviderErrorKind

Source§

impl PartialEq for ProviderErrorKind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ProviderErrorKind

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ProviderErrorKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more