Error Handling
The Smartbills Python SDK raises structured exceptions for every API failure. Each exception class maps to a specific HTTP status code and includes contextual information for debugging.Error hierarchy
All SDK errors inherit fromSmartbillsApiError:
SmartbillsApiError (base)
Every error includes these attributes:Error types
SmartbillsValidationError (400)
Raised when the request body fails server-side validation. Includes a list of field-level errors.SmartbillsAuthenticationError (401)
Raised when the access token is missing, expired, or invalid.SmartbillsPermissionError (403)
Raised when the authenticated user lacks permission for the requested action.SmartbillsNotFoundError (404)
Raised when the requested resource does not exist.SmartbillsConflictError (409)
Raised when the request conflicts with the current state of the resource.SmartbillsRateLimitError (429)
Raised when the API rate limit is exceeded. Includes aretry_after hint.
SmartbillsQuotaError (402/403)
Raised when the business has exceeded its plan quota.Comprehensive error handler
Retry pattern
The SDK has built-in retry for transient errors (429, 5xx, network errors). For additional control, implement your own retry logic:Automatic retry behavior
The SDK automatically retries the following scenarios:
Non-retryable errors (400, 401, 403, 404, 409) are raised immediately without retry.
The maximum number of retries and base delay are configured via
SmartbillsClientOptions: