ExLLM.Adapters.Shared.ErrorHandler (ex_llm v0.5.0)
View SourceShared error handling utilities for ExLLM adapters.
Provides consistent error handling patterns across all provider adapters, including provider-specific error parsing and standardization.
Summary
Functions
Extract error message from various response formats.
Extract retry-after header value if present.
Handle provider-specific errors and convert to standard ExLLM errors.
Normalize error responses across providers for consistent handling.
Check if an error is retryable based on status code and error type.
Check if an error should trigger a retry based on provider-specific rules.
Functions
Extract error message from various response formats.
Extract retry-after header value if present.
Handle provider-specific errors and convert to standard ExLLM errors.
Examples
# OpenAI-style error
ErrorHandler.handle_provider_error(:openai, 429, %{
"error" => %{
"type" => "rate_limit_error",
"message" => "Rate limit exceeded"
}
})
# Anthropic-style error
ErrorHandler.handle_provider_error(:anthropic, 400, %{
"error" => %{
"type" => "invalid_request_error",
"message" => "max_tokens required"
}
})
Normalize error responses across providers for consistent handling.
Returns a standardized error tuple.
Check if an error is retryable based on status code and error type.
Check if an error should trigger a retry based on provider-specific rules.