Error Codes
Cadenza uses a standardized error code system across both HTTP and WebSocket APIs.
Response Format
HTTP API
{
"data": null,
"success": false,
"errno": -22016,
"error": "Resource not found"
}
WebSocket API
{
"error": {
"code": 22016,
"message": "Not found"
}
}
note
HTTP API returns negative codes (-22016), WebSocket returns positive codes (22016). The absolute values are the same.
Error Code Format
Error codes use a 5-digit format: DDCCC
- DD: Domain (2 digits) - System layer
- CCC: Specific Error (3 digits) - Unique error within domain
Example: 22016 = Use Case (22) + Not Found (016)
Error Code Ranges
| Range | Category | Description |
|---|---|---|
18xxx | Market Connector | Exchange integration errors |
19xxx | Web/HTTP | Web layer errors |
22xxx | Use Case | Business logic errors |
26xxx | Authentication | Auth errors |
Market Connector Errors (18xxx)
Exchange integration errors:
| Code | HTTP | Message |
|---|---|---|
| 18000 | 500 | Unknown error |
| 18001 | 400 | Order type not supported |
| 18002 | 400 | Order side not supported |
| 18003 | 400 | Time in force not supported |
| 18004 | 502 | Exchange error |
| 18005 | 401 | Authentication error |
| 18006 | 400 | Insufficient funds |
| 18007 | 400 | Invalid order |
| 18008 | 400 | Bad request |
| 18009 | 502 | Network error |
| 18010 | 503 | DDOS protection |
| 18011 | 429 | Rate limit exceeded |
| 18012 | 503 | Exchange not available |
| 18013 | 503 | On maintenance |
| 18015 | 504 | Request timeout |
| 18016 | 501 | Not supported |
| 18017 | 404 | Symbol not found |
| 18018 | 404 | Order not found |
| 18019 | 404 | Position not found |
| 18020 | 404 | Balance not found |
| 18022 | 401 | Invalid API key |
| 18025 | 400 | Order rejected |
Web/HTTP Errors (19xxx)
| Code | HTTP | Message | Description |
|---|---|---|---|
| 19000 | 500 | Base web error | General web error |
| 19001 | 400 | Bad request | Invalid request syntax |
| 19002 | 401 | Unauthorized | Auth required |
| 19003 | 404 | Page not found | Endpoint not found |
| 19004 | 400 | Form validation failed | Validation error |
| 19005 | 400 | Invalid JSON | Malformed JSON |
| 19006 | 503 | Service unavailable | Temporarily unavailable |
Use Case Errors (22xxx)
Common business logic errors:
| Code | HTTP | Message |
|---|---|---|
| 22000 | 500 | Unknown error |
| 22014 | 503 | Lock not acquired |
| 22015 | 400 | Invalid argument |
| 22016 | 404 | Not found |
| 22017 | 409 | Already exist |
| 22018 | 403 | Permission denied |
| 22019 | 501 | Operation unsupported |
| 22021 | 503 | Database failure |
| 22023 | 401 | Unauthorized |
| 22028 | 500 | Cache not hit |
| 22029 | 400 | Bad request |
| 22031 | 504 | Timeout |
Authentication Errors (26xxx)
| Code | HTTP | Message | Description |
|---|---|---|---|
| 26001 | 400 | Invalid request | Bad email/password format |
| 26002 | 401 | Invalid credentials | Wrong password |
| 26003 | 401 | Token expired | Access token expired |
| 26004 | 401 | Invalid token | Token invalid or malformed |
| 26005 | 401 | Missing authorization | No Authorization header |
| 26006 | 429 | Rate limited | Too many auth attempts |
Error Handling
HTTP API (Python)
def handle_response(response):
data = response.json()
if data["success"]:
return data["data"]
errno = abs(data["errno"]) # Convert to positive
error = data["error"]
if errno == 22016:
raise NotFoundError(error)
elif errno == 22023:
raise UnauthorizedError(error)
raise APIError(errno, error)
WebSocket API (Python)
from centrifuge import RpcError
async def safe_rpc(client, method, params):
try:
result = await client.rpc(method, params)
return result.data
except RpcError as e:
if e.code == 22016:
return None # Not found
elif e.code == 22023:
raise UnauthorizedError(e.message)
raise
See Also
- Authentication - Auth flow
- HTTP API - REST API documentation
- WebSocket API - WebSocket documentation