pub enum AiMuxError {
Show 16 variants
ApiCall(Box<ApiCallError>),
Retry(RetryError),
JsonParse(String),
InvalidResponseData(String),
NoSuchTool {
tool_name: String,
available_tools: Option<Vec<String>>,
tool_input: Option<String>,
},
InvalidToolInput {
tool_name: String,
tool_input: String,
cause: String,
},
ToolCallRepair {
original_error: Box<AiMuxError>,
cause: Box<AiMuxError>,
},
InvalidArgument(String),
InvalidPrompt(String),
TokenExpired(String),
UnsupportedFunctionality(String),
NoSuchModel {
model_id: String,
model_type: String,
},
NoSuchProvider {
provider_id: String,
},
Timeout(String),
Aborted(String),
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. ApiCallError is boxed only to keep the Rust enum
compact; serde and every binding still observe the same object shape.
Variants§
ApiCall(Box<ApiCallError>)
Retry(RetryError)
JsonParse(String)
InvalidResponseData(String)
NoSuchTool
A model requested a tool that was not present in the call’s tool set.
Message templates for the three tool variants match the AI SDK verbatim
(NoSuchToolError / InvalidToolInputError / ToolCallRepairError):
the AI SDK feeds these strings back to the model as tool-error content,
so the wording — including the available-tools list — is contract.
Fields
InvalidToolInput
A tool call could not be parsed or did not satisfy its input schema.
ToolCallRepair
The repair callback failed or returned a call that was still invalid.
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(String)
Other(String)
Implementations§
Source§impl AiMuxError
impl AiMuxError
Sourcepub fn is_recoverable_stream_error(&self) -> bool
pub fn is_recoverable_stream_error(&self) -> bool
Returns true for a malformed individual stream frame that does not
prove the underlying transport has failed. Stream reducers may report
these errors and continue polling for later, independently framed data.
Sourcepub fn from_abort_signal(_signal: &AbortSignal) -> Self
pub fn from_abort_signal(_signal: &AbortSignal) -> Self
Convert caller cancellation into the public error model.
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’s response headers, if any.
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 selected response
handler filled when a response actually arrived. 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§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