Skip to main content

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

RangeCategoryDescription
18xxxMarket ConnectorExchange integration errors
19xxxWeb/HTTPWeb layer errors
22xxxUse CaseBusiness logic errors
26xxxAuthenticationAuth errors

Market Connector Errors (18xxx)

Exchange integration errors:

CodeHTTPMessage
18000500Unknown error
18001400Order type not supported
18002400Order side not supported
18003400Time in force not supported
18004502Exchange error
18005401Authentication error
18006400Insufficient funds
18007400Invalid order
18008400Bad request
18009502Network error
18010503DDOS protection
18011429Rate limit exceeded
18012503Exchange not available
18013503On maintenance
18015504Request timeout
18016501Not supported
18017404Symbol not found
18018404Order not found
18019404Position not found
18020404Balance not found
18022401Invalid API key
18025400Order rejected

Web/HTTP Errors (19xxx)

CodeHTTPMessageDescription
19000500Base web errorGeneral web error
19001400Bad requestInvalid request syntax
19002401UnauthorizedAuth required
19003404Page not foundEndpoint not found
19004400Form validation failedValidation error
19005400Invalid JSONMalformed JSON
19006503Service unavailableTemporarily unavailable

Use Case Errors (22xxx)

Common business logic errors:

CodeHTTPMessage
22000500Unknown error
22014503Lock not acquired
22015400Invalid argument
22016404Not found
22017409Already exist
22018403Permission denied
22019501Operation unsupported
22021503Database failure
22023401Unauthorized
22028500Cache not hit
22029400Bad request
22031504Timeout

Authentication Errors (26xxx)

CodeHTTPMessageDescription
26001400Invalid requestBad email/password format
26002401Invalid credentialsWrong password
26003401Token expiredAccess token expired
26004401Invalid tokenToken invalid or malformed
26005401Missing authorizationNo Authorization header
26006429Rate limitedToo 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