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.
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
impl Error
Sourcepub fn is_transient(&self) -> bool
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.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Extract the retry-after duration from a Provider error, if present.
Sourcepub fn http_status(&self) -> u16
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.
Sourcepub fn kind(&self) -> &'static str
pub fn kind(&self) -> &'static str
OpenAI-compatible error type for the client-facing ApiError.
Sourcepub fn not_implemented(method: &str) -> Self
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 Error for Error
impl Error for Error
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()