MistralClient.Errors (mistralex_ai v0.1.0)
View SourceError definitions and handling for the Mistral AI client.
This module defines standardized error types that can occur when interacting with the Mistral API, providing consistent error handling across the SDK.
Error Types
APIError
- General API errors (4xx, 5xx responses)AuthenticationError
- Authentication failures (401)PermissionError
- Permission denied (403)NotFoundError
- Resource not found (404)RateLimitError
- Rate limit exceeded (429)ServerError
- Server-side errors (5xx)NetworkError
- Network connectivity issuesTimeoutError
- Request timeoutValidationError
- Request validation failuresConfigurationError
- Configuration issues
Usage
case MistralClient.chat(messages) do
{:ok, response} -> handle_success(response)
{:error, %MistralClient.Errors.RateLimitError{} = rate_limit_error} ->
# Handle rate limiting
retry_after_delay(rate_limit_error.retry_after)
{:error, other_error} ->
# Handle other errors
Logger.error("API error: inspect(other_error)")
end
Summary
Functions
Convert an HTTP response to an appropriate error.
Functions
@spec from_response(integer(), String.t() | nil, list() | map()) :: Exception.t()
Convert an HTTP response to an appropriate error.
Parameters
status_code
- HTTP status coderesponse_body
- Response body (optional)headers
- Response headers (optional)
Examples
error = MistralClient.Errors.from_response(401, "Unauthorized")
%MistralClient.Errors.AuthenticationError{}