Skip to main content

Module error

Module error 

Source
Expand description

Unified error type for all LLM operations.

Every provider maps its native errors into LlmError, giving callers a single type to match against regardless of which backend is in use. Variants carry enough context for retry logic, user-facing messages, and diagnostics.

§Retryability

Several variants include a retryable flag that providers set based on the upstream response (e.g. HTTP 429 or 503). Middleware layers can inspect this flag to decide whether to retry automatically:

use llm_stack::LlmError;

fn should_retry(err: &LlmError) -> bool {
    match err {
        LlmError::Http { retryable, .. } => *retryable,
        LlmError::Provider { retryable, .. } => *retryable,
        LlmError::Timeout { .. } => true,
        _ => false,
    }
}

Enums§

LlmError
The unified error type returned by all provider operations.