Error Handling
The Paradex WebSocket API uses JSON-RPC 2.0 for communication, which includes standardized error handling. This page explains the error format and common error codes.
Error Message Format
When an error occurs, the WebSocket API returns an error message with the following format:
Error Object Properties
Error Codes
The Paradex WebSocket API uses standard JSON-RPC error codes as well as custom error codes.
Standard JSON-RPC Error Codes
Error codes from -32768 to -32000 are pre-defined errors per the JSON-RPC specification:
Paradex-Specific Error Codes
Other errors are specific to the Paradex WebSocket API:
Common Error Scenarios
Authentication Errors
Authentication errors occur when there are issues with the JWT token:
Subscription Errors
Subscription errors occur when there are issues with channel subscriptions:
Method Errors
Method errors occur when an invalid method is called:
Best Practices for Error Handling
- Check Error Codes: Always check the error code to understand the type of error
- Log Errors: Log all errors for debugging purposes
- Implement Retry Logic: For transient errors, implement retry logic with exponential backoff
- Handle Authentication Errors: If you receive an authentication error, regenerate your JWT token and reconnect
- Validate Parameters: Ensure all parameters are valid before sending requests