pub enum AiMuxError {
Show 13 variants
ApiCall(ApiCallError),
JsonParse(String),
InvalidResponseData(String),
Tool(String),
InvalidArgument(String),
InvalidPrompt(String),
TokenExpired(String),
UnsupportedFunctionality(String),
NoSuchModel {
model_id: String,
model_type: String,
},
NoSuchProvider {
provider_id: String,
},
Timeout(String),
Aborted,
Other(String),
}Expand description
Unified error type for all aimux operations.
Variants are cut by what the caller does about it, not by where the
failure came from. ApiCall carries the ApiCallError detail inline
(unboxed, like async-openai’s ApiError(ApiError)); the size guard in
error_value_golden_test keeps the enum under clippy’s
result_large_err threshold.
Constructed as a named struct literal everywhere
(ApiCallError { status_code: .., ..Default::default() }), the same
shape as the AI SDK’s named-options constructor.
Variants§
ApiCall(ApiCallError)
JsonParse(String)
InvalidResponseData(String)
Tool(String)
InvalidArgument(String)
InvalidPrompt(String)
TokenExpired(String)
The access token has expired (or was invalidated) and must be refreshed
by the caller. RFC-0018 subscription mode: the library maps a 401 from
the Codex subscription endpoint to this variant; the integrator
orchestrates codex_refresh + retry.
This is not a status-code avatar: Auth-style 401s and token
expiry share the same status, so status_code alone cannot express
the difference — the variant carries the extra bit (“refresh helps”).
UnsupportedFunctionality(String)
NoSuchModel
Registry-level “model id does not resolve” (the AI SDK’s
NoSuchModelError { modelId, modelType }). Pre-HTTP: the upstream API
was never called, so there is no status.
Fields
NoSuchProvider
Registry-level “provider name does not resolve” (the AI SDK’s
NoSuchProviderError).
Timeout(String)
Aborted
Other(String)
Implementations§
Source§impl AiMuxError
impl AiMuxError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if the error is transient and can be retried.
Reads the stored ApiCallError::is_retryable field, filled at
construction (the AI SDK’s APICallError.isRetryable): 408/409/429/5xx on the
response path, true on the transport path. Timeout is a spent
caller-side time budget — the AI SDK treats it as part of the abort
family (isAbortError matches "TimeoutError") and does not retry
it; neither do we.
Sourcepub fn retry_after_hint(&self) -> Option<i64>
pub fn retry_after_hint(&self) -> Option<i64>
Returns the retry-after delay hint (in milliseconds) carried by this
error, if any — distilled from the retry-after-ms / retry-after
response headers into ApiCallError::retry_after_ms. Returns None
for errors that don’t advertise a delay, in which case the retry
strategy falls back to exponential backoff.
Mirrors the header-consulting behaviour of
retryWithExponentialBackoffRespectingRetryHeaders in the TS SDK.
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
Returns the HTTP status code carried by this error, if any.
This is the observed status only — the field the HTTP layer filled
when a response actually arrived (parse_provider_error,
send_with_retry_raw). An error built without an HTTP exchange (a
missing API key, a bare constructor, a transport failure) reports
None: no status was seen, so none is invented.
TokenExpired reports Some(401) by definition, not by fabrication:
its only producer is the codex subscription channel’s observed-401
mapping (RFC-0018), which trades the carried fields for the “refresh
helps” bit — the status is part of the variant’s contract.
Trait Implementations§
Source§impl Clone for AiMuxError
impl Clone for AiMuxError
Source§fn clone(&self) -> AiMuxError
fn clone(&self) -> AiMuxError
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 AiMuxError
impl Debug for AiMuxError
Source§impl<'de> Deserialize<'de> for AiMuxError
impl<'de> Deserialize<'de> for AiMuxError
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 AiMuxError
impl Display for AiMuxError
Source§impl Error for AiMuxError
impl Error for AiMuxError
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()
Source§impl From<Error> for AiMuxError
Canonical serde classification: syntactically broken/truncated JSON is a
parse failure; well-formed JSON that violates the expected shape is invalid
response data. Io has no transport context here, so it stays JsonParse;
call sites with a concrete transport error should preserve that instead.
impl From<Error> for AiMuxError
Canonical serde classification: syntactically broken/truncated JSON is a
parse failure; well-formed JSON that violates the expected shape is invalid
response data. Io has no transport context here, so it stays JsonParse;
call sites with a concrete transport error should preserve that instead.
Source§impl Serialize for AiMuxError
impl Serialize for AiMuxError
Source§impl TS for AiMuxError
impl TS for AiMuxError
Source§type WithoutGenerics = AiMuxError
type WithoutGenerics = AiMuxError
WithoutGenerics should just be Self.
If the type does have generic parameters, then all generic parameters must be replaced with
a dummy type, e.g ts_rs::Dummy or (). The only requirement for these dummy types is that
EXPORT_TO must be None. Read moreSource§type OptionInnerType = AiMuxError
type OptionInnerType = AiMuxError
std::option::Option<T>, then this associated type is set to T.
All other implementations of TS should set this type to Self instead.Source§fn docs() -> Option<String>
fn docs() -> Option<String>
TS is derived, docs are
automatically read from your doc comments or #[doc = ".."] attributesSource§fn decl_concrete(cfg: &Config) -> String
fn decl_concrete(cfg: &Config) -> String
TS::decl().
If this type is not generic, then this function is equivalent to TS::decl().Source§fn decl(cfg: &Config) -> String
fn decl(cfg: &Config) -> String
type User = { user_id: number, ... }.
This function will panic if the type has no declaration. Read moreSource§fn inline(cfg: &Config) -> String
fn inline(cfg: &Config) -> String
{ user_id: number }.
This function will panic if the type cannot be inlined.Source§fn inline_flattened(cfg: &Config) -> String
fn inline_flattened(cfg: &Config) -> String
Source§fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn output_path() -> Option<PathBuf>
fn output_path() -> Option<PathBuf>
T should be exported, relative to the output directory.
The returned path does not include any base directory. Read moreSource§fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn dependencies(cfg: &Config) -> Vec<Dependency>where
Self: 'static,
fn dependencies(cfg: &Config) -> Vec<Dependency>where
Self: 'static,
Source§fn export(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
fn export(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
TS::export_all. Read moreSource§fn export_all(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
fn export_all(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
TS::export. Read more