Documentation Index
Fetch the complete documentation index at: https://mintlify.com/reductoai/reducto-python-sdk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Reducto Python SDK provides a comprehensive set of exception classes to handle different error scenarios. All exceptions inherit fromreducto.APIError, making it easy to catch all API-related errors.
Exception Hierarchy
Exception Classes
ReductoError
Base exception class for all Reducto errors.APIError
Base class for all API-related errors. Contains information about the request and response. Attributes:message(str): Error message describing what went wrongrequest(httpx.Request): The HTTP request that caused the errorbody(object | None): The API response body. If the API responded with valid JSON, this will be the decoded result. Otherwise, it will be the raw response.Noneif there was no response.
APIConnectionError
Raised when the library is unable to connect to the API (e.g., network connection problems). Attributes:- Inherits all attributes from
APIError - Default message: “Connection error.”
APITimeoutError
Raised when a request times out. Attributes:- Inherits all attributes from
APIConnectionError - Default message: “Request timed out.”
Requests that time out are automatically retried twice by default. See the Retries section for more information.
APIResponseValidationError
Raised when the API returns data that is invalid for the expected schema. Attributes:response(httpx.Response): The HTTP response objectstatus_code(int): The HTTP status code- Default message: “Data returned by API invalid for expected schema.”
APIStatusError
Raised when an API response has a status code of 4xx or 5xx. Attributes:response(httpx.Response): The HTTP response objectstatus_code(int): The HTTP status codemessage(str): Error message from the APIbody(object | None): The response body
HTTP Status Code Exceptions
The following exceptions correspond to specific HTTP status codes:| Status Code | Exception Class | Description |
|---|---|---|
| 400 | BadRequestError | The request was malformed or invalid |
| 401 | AuthenticationError | Authentication failed or API key is invalid |
| 403 | PermissionDeniedError | The API key doesn’t have permission to perform this operation |
| 404 | NotFoundError | The requested resource was not found |
| 409 | ConflictError | The request conflicts with the current state |
| 422 | UnprocessableEntityError | The request was well-formed but contains semantic errors |
| 429 | RateLimitError | Too many requests; rate limit exceeded |
| >=500 | InternalServerError | Server-side error occurred |
APIStatusError and include the status_code, response, and body attributes.
Error Handling Example
Here’s how to properly handle errors when using the Reducto SDK:Retries
Certain errors are automatically retried 2 times by default with a short exponential backoff:- Connection errors (network connectivity issues)
- 408 Request Timeout
- 409 Conflict
- 429 Rate Limit
-
=500 Internal Server Errors
Best Practices
-
Catch specific exceptions first: Always catch more specific exceptions (like
RateLimitError) before catching general ones (likeAPIStatusErrororAPIError). -
Handle connection errors: Network issues are common, so always handle
APIConnectionErrorandAPITimeoutError. -
Inspect error details: Use the
status_code,response, andbodyattributes to get detailed information about what went wrong. -
Implement backoff for rate limits: When catching
RateLimitError, implement an exponential backoff strategy before retrying. -
Log error context: The
requestattribute on all API errors contains the original request, which is useful for debugging.