Skip to main content

Error

Enum Error 

Source
pub enum Error {
    Config(String),
    Provider {
        status: u16,
        body: String,
        retry_after: Option<Duration>,
    },
    Network(String),
    Decode(String),
    Encode(String),
    Invalid(String),
    Unsupported(String),
    Routing(String),
    Timeout,
    Internal(String),
}
Expand description

Shared error type for the crabllm workspace.

Every variant carries enough structure that retry semantics (Error::is_transient), HTTP status (Error::http_status), and the client-facing error type (Error::kind) are derivable from the variant alone — never from string contents. Layers must NOT stringify-and-rewrap an inner error (Error::Internal(format!("...: {e}"))); propagate the inner Error or classify the cause into the right variant instead.

Variants§

§

Config(String)

TOML config parse error or missing env var. Startup only.

§

Provider

Upstream provider returned (or streamed) an error. body is the upstream’s own message, passed through verbatim — never prefixed.

Fields

§status: u16
§body: String
§retry_after: Option<Duration>
§

Network(String)

Transport failure talking to the upstream: connect, send, or reading a (possibly mid-stream) response body. Transient.

§

Decode(String)

An upstream response body could not be deserialized into our types. Not transient — retrying yields the same unparseable bytes.

§

Encode(String)

Our own request could not be serialized. A bug on our side, not the upstream’s. Not transient.

§

Invalid(String)

The client’s request is malformed or violates a precondition (e.g. a body that doesn’t match the schema, or an unsupported option combination). The client’s fault — not transient, 400.

§

Unsupported(String)

A provider does not implement the requested operation.

§

Routing(String)

Request could not be routed: unknown model or no matching deployment.

§

Timeout

Request to upstream provider timed out.

§

Internal(String)

Genuine catch-all for internal bugs. Not transient — if it happens, retrying won’t help.

Implementations§

Source§

impl Error

Source

pub fn is_transient(&self) -> bool

Whether this error is transient and the request should be retried. Only network failures, timeouts, and upstream 429/5xx are transient; everything else (decode, encode, unsupported, routing, internal) is deterministic and must not be retried.

Source

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

Extract the retry-after duration from a Provider error, if present.

Source

pub fn http_status(&self) -> u16

HTTP status to return to the client for this error. Single source of truth for the proxy’s error-to-response mapping.

Source

pub fn kind(&self) -> &'static str

OpenAI-compatible error type for the client-facing ApiError.

Source

pub fn not_implemented(method: &str) -> Self

Build an “operation not supported” error for a provider trait method that has no implementation. Used by Provider trait default impls. Distinct from per-provider rejection messages so log lines can be disambiguated by grep.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V