Error Codes Reference
This document provides a comprehensive reference for all error codes used in the API. Each error includes a unique code, message, HTTP status, and category for easier debugging and error handling.
Error Structure
All errors follow a consistent structure:
{
code: string; // Unique error identifier (e.g., "AUTH_001")
message: string; // Human-readable error message
httpStatus: number; // HTTP status code
category: string; // Error category (e.g., "AUTH", "VALIDATION")
}Error Categories
AUTH - Authentication & Authorization Errors
Errors related to authentication, authorization, and access control.
| Code | Message | HTTP Status | Description |
|---|---|---|---|
AUTH_001 | Unauthorized access | 401 | The request requires authentication or the provided credentials are invalid |
AUTH_002 | Invalid API key provided | 401 | The API key is malformed, expired, or doesn’t exist |
AUTH_003 | Admin key required for this operation | 401 | This operation requires admin-level privileges |
AUTH_004 | Invalid or malformed JWT token | 401 | The JWT token structure is invalid or corrupted |
AUTH_005 | JWT token has expired | 401 | The JWT token has passed its expiration time |
AUTH_006 | Invalid nonce provided | 401 | The nonce value is incorrect or doesn’t match |
AUTH_007 | Nonce has expired | 401 | The nonce has exceeded its time-to-live |
AUTH_008 | Invalid wallet signature | 401 | The cryptographic signature verification failed |
VALIDATION - Input Validation Errors
Errors related to request data validation and format checking.
| Code | Message | HTTP Status | Description |
|---|---|---|---|
VALIDATION_001 | Invalid input data | 400 | The provided input data is malformed or invalid |
VALIDATION_002 | Invalid address format | 400 | The blockchain address format is incorrect |
VALIDATION_003 | Invalid or unsupported chain ID | 400 | The chain ID is not recognized or supported |
VALIDATION_004 | Request validation failed | 400 | The request failed schema validation |
TRANSACTION - Transaction Processing Errors
Errors related to blockchain transactions and processing.
| Code | Message | HTTP Status | Description |
|---|---|---|---|
TRANSACTION_001 | Transaction cost exceeds maximum allowed limit | 400 | The transaction cost is higher than the configured maximum |
TRANSACTION_002 | Insufficient balance to process transaction | 400 | The account doesn’t have enough funds |
TRANSACTION_003 | Transaction not found | 404 | The requested transaction doesn’t exist |
TRANSACTION_004 | Error processing transaction | 500 | An unexpected error occurred during transaction processing |
TRANSACTION_005 | Invalid gas parameters provided | 400 | Gas price or gas limit values are invalid |
TRANSACTION_006 | Daily limit exceeded, can not process transaction | 400 | The daily transaction limit has been reached |
USER - User Management Errors
Errors related to user accounts and management.
| Code | Message | HTTP Status | Description |
|---|---|---|---|
USER_001 | User not found | 404 | The specified user doesn’t exist in the system |
USER_002 | User already exists | 400 | A user with this identifier already exists |
USER_003 | Invalid user address | 400 | The user’s address is malformed or invalid |
USER_004 | User account has been disabled | 403 | The user account has been deactivated |
SYSTEM - System-Level Errors
Errors related to system operations and infrastructure.
| Code | Message | HTTP Status | Description |
|---|---|---|---|
SYSTEM_001 | Database operation failed | 500 | A database query or operation failed |
SYSTEM_002 | Internal server error | 500 | An unexpected internal error occurred |
SYSTEM_003 | Service temporarily unavailable | 503 | The service is temporarily down or overloaded |
CHAIN - Blockchain Errors
Errors related to blockchain network operations.
| Code | Message | HTTP Status | Description |
|---|---|---|---|
CHAIN_001 | Unsupported blockchain network | 400 | The specified blockchain is not supported |
CHAIN_002 | Chain adapter operation failed | 500 | The blockchain adapter encountered an error |
CHAIN_003 | Blockchain RPC error | 500 | Communication with the blockchain node failed |
CHAIN_004 | Network connectivity error | 503 | Unable to connect to the blockchain network |
RESOURCE - Resource Management Errors
Errors related to resource access and limits.
| Code | Message | HTTP Status | Description |
|---|---|---|---|
RESOURCE_001 | Requested resource not found | 404 | The requested resource doesn’t exist |
RESOURCE_002 | Resource conflict detected | 409 | A conflict occurred with the current state |
RESOURCE_003 | Resource limit exceeded | 429 | Rate limit or resource quota exceeded |
Usage Examples
Handling Errors in TypeScript
import { ErrorCodes } from './error-codes';
try {
// API call
} catch (error) {
if (error.code === ErrorCodes.AUTH_TOKEN_EXPIRED.code) {
// Refresh token and retry
} else if (error.code === ErrorCodes.TRANSACTION_INSUFFICIENT_BALANCE.code) {
// Show insufficient balance error to user
} else {
// Handle other errors
}
}Filtering by Category
import { getErrorCodesByCategory } from './error-codes';
// Get all authentication errors
const authErrors = getErrorCodesByCategory('AUTH');
console.log(authErrors);Getting All Categories
import { getErrorCategories } from './error-codes';
const categories = getErrorCategories();
// Returns: ['AUTH', 'VALIDATION', 'TRANSACTION', 'USER', 'SYSTEM', 'CHAIN', 'RESOURCE']HTTP Status Code Summary
| Status | Meaning | Error Categories |
|---|---|---|
| 400 | Bad Request | VALIDATION, TRANSACTION, USER, CHAIN, RESOURCE |
| 401 | Unauthorized | AUTH |
| 403 | Forbidden | USER |
| 404 | Not Found | TRANSACTION, USER, RESOURCE |
| 409 | Conflict | RESOURCE |
| 429 | Too Many Requests | RESOURCE |
| 500 | Internal Server Error | TRANSACTION, SYSTEM, CHAIN |
| 503 | Service Unavailable | SYSTEM, CHAIN |
Best Practices
- Always check the error code - Use the specific error code rather than just the HTTP status for precise error handling
- Log error codes - Include error codes in your logs for easier debugging and monitoring
- User-friendly messages - Map error codes to user-friendly messages in your frontend
- Retry logic - Implement appropriate retry logic for transient errors (503, CHAIN_004)
- Rate limiting - Handle
RESOURCE_003by implementing exponential backoff
Common Error Scenarios
Authentication Flow
AUTH_006→AUTH_007→AUTH_008→ Success- If any step fails, return the appropriate auth error
Transaction Processing
- Validate input →
VALIDATION_*errors - Check balance →
TRANSACTION_002 - Check limits →
TRANSACTION_001orTRANSACTION_006 - Process →
TRANSACTION_004orCHAIN_*errors
User Operations
- Validate address →
USER_003 - Check existence →
USER_001orUSER_002 - Check status →
USER_004 - Process operation
Last updated on