Skip to main content

Exception Hierarchy

All SDK exceptions extend from XpozError. Import them from the package:
The Python SDK includes two additional exception types not present in the TypeScript SDK: NotFoundError and ValidationError. These provide more granular error handling for common input issues.

Catching Exceptions

Use except clauses to handle specific exception types. Always catch more specific exceptions before the base XpozError:

Exception Details

AuthenticationError

Raised when the access key is invalid, expired, or missing.

OperationTimeoutError

Raised when an operation exceeds the configured timeout (default: 300 seconds). The exception includes the elapsed time.
If you frequently hit timeouts, increase the timeout when creating the client: XpozClient("key", timeout=600). You can also narrow your queries with date filters, field selection, or more specific search terms.

OperationFailedError

Raised when an operation completes but with an error status. Includes the operation_id and error details.

OperationCancelledError

Raised when an operation is cancelled, typically due to server-side resource management.

NotFoundError

Raised when a requested resource (user, post, subreddit) does not exist.

ValidationError

Raised when invalid parameters are passed to a method.

Practical Pattern

A robust wrapper that handles all error cases:
For the equivalent error handling patterns in TypeScript, see TypeScript SDK Error Handling. The TypeScript SDK uses try/catch with instanceof checks instead of try/except.