Skip to main content

Exception Hierarchy

Error Types

LexaError (Base Exception)

All Lexa-specific exceptions inherit from LexaError.

LexaAuthError

Raised when API key authentication or authorization fails.
Status Codes:
  • 401 - Invalid or expired API key
  • 403 - Access forbidden (insufficient permissions)

LexaRateLimitError

Raised when API rate limits are exceeded.
Status Code: 429

LexaValidationError

Raised when request parameters are invalid.
Status Code: 400

LexaJobFailedError

Raised when document processing fails on the server side.
Common Failure Reasons:
  • invalid_file_format - Unsupported file format (not retryable)
  • file_corrupted - File is corrupted (not retryable)
  • file_too_large - File exceeds size limits (not retryable)
  • unsupported_format - Format not supported (not retryable)
  • temporary_server_error - Temporary issue (retryable)

LexaUnsupportedFileError

Raised when attempting to process unsupported file formats.
Status Code: 415

LexaTimeoutError

Raised when operations exceed timeout limits.
Status Code: 408

LexaQuotaExceededError

Raised when usage quotas are exceeded.
Status Code: 402

LexaServerError

Raised for server-side errors (5xx status codes).
Status Codes: 500, 502, 503, 504

Intelligent Error Classification

The SDK provides intelligent error classification through the create_error_from_response function.

Retry Strategies

The SDK provides intelligent retry guidance through the get_retry_strategy function.

Best Practices

Comprehensive Error Handling

Error Monitoring and Logging

Graceful Degradation

Error Recovery Patterns

Circuit Breaker Pattern


Next Steps

Learn about client configuration for optimal performance and reliability.