#[non_exhaustive]pub enum FMError {
Show 17 variants
ModelUnavailable {
reason: Unavailability,
message: String,
},
GuardrailViolation(String),
ContextWindowExceeded(String),
UnsupportedLanguage(String),
AssetsUnavailable(String),
RateLimited(String),
DecodingFailure(String),
Refusal(String),
ConcurrentRequests(String),
UnsupportedGuide(String),
ToolCallFailed(String),
AdapterInvalidAsset(String),
AdapterInvalidName(String),
AdapterCompatibleNotFound(String),
Cancelled,
InvalidArgument(String),
Unknown {
code: i32,
message: String,
},
}Expand description
Top-level error type returned by all fallible APIs in this crate.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
FoundationModels is not available on this device.
See Unavailability for the specific reason.
GuardrailViolation(String)
The model refused to produce a response because the prompt or generated content tripped a safety guardrail.
ContextWindowExceeded(String)
The combined prompt + history exceeds the model’s context window.
UnsupportedLanguage(String)
The requested locale or language is not supported by the on-device model.
On-device model assets are still downloading or otherwise unavailable.
RateLimited(String)
The session was rate-limited (typically only relevant on Mac with extended generation budgets).
DecodingFailure(String)
Structured generation failed to decode the model’s output into the
requested Generable schema.
Refusal(String)
The model refused the request (distinct from a guardrail violation — the model itself declined to answer).
ConcurrentRequests(String)
Too many concurrent generation requests against the same session.
UnsupportedGuide(String)
The supplied [GenerationGuide] is unsupported by the on-device model.
ToolCallFailed(String)
A tool invocation failed while the model was using Tool calling.
AdapterInvalidAsset(String)
An adapter asset pack was invalid.
AdapterInvalidName(String)
The requested adapter name was invalid.
AdapterCompatibleNotFound(String)
No compatible adapter could be found for the requested name.
Cancelled
The generation Task was cancelled before completion.
InvalidArgument(String)
An invalid argument crossed the FFI boundary (e.g. a NUL byte in a prompt).
Unknown
Implementations§
Trait Implementations§
Source§impl Error for FMError
impl Error for FMError
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()