#[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 crate::schema::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§
Source§impl FMError
impl FMError
Sourcepub const fn code(&self) -> i32
pub const fn code(&self) -> i32
Numeric status code reported by the Swift bridge. Useful for matching
against crate::ffi::status constants.
Sourcepub fn message(&self) -> &str
pub fn message(&self) -> &str
Human-readable description (forwarded from Error.localizedDescription).
Sourcepub fn generation_error_context(&self) -> Option<GenerationErrorContext>
pub fn generation_error_context(&self) -> Option<GenerationErrorContext>
Structured generation-error context, when available.
Sourcepub fn adapter_asset_error_context(&self) -> Option<AdapterAssetErrorContext>
pub fn adapter_asset_error_context(&self) -> Option<AdapterAssetErrorContext>
Structured adapter-asset error context, when available.
Sourcepub fn schema_error_context(&self) -> Option<SchemaErrorContext>
pub fn schema_error_context(&self) -> Option<SchemaErrorContext>
Structured schema-error context, when available.
Sourcepub fn recovery_suggestion(&self) -> Option<String>
pub fn recovery_suggestion(&self) -> Option<String>
Localized recovery suggestion, when the SDK provided one.
Sourcepub fn failure_reason(&self) -> Option<String>
pub fn failure_reason(&self) -> Option<String>
Localized failure reason, when the SDK provided one.
Sourcepub fn refusal(&self) -> Option<Refusal>
pub fn refusal(&self) -> Option<Refusal>
Typed refusal helper, when this error came from a refusal.
Sourcepub fn tool_call_error(&self) -> Option<ToolCallError>
pub fn tool_call_error(&self) -> Option<ToolCallError>
Typed tool-call failure metadata, when available.
Trait Implementations§
impl Eq for FMError
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()