RebelfiError Class
All API errors are thrown asRebelfiError instances with structured information:
Properties
| Property | Type | Description |
|---|---|---|
message | string | Human-readable error message |
statusCode | number | HTTP status code |
code | ErrorCode | Machine-readable error code |
details | object | Additional error context |
Checking Error Type
Use the.is() method to check for specific errors:
Error Codes
Validation Errors (4xx)
| Code | Description | Recommended Action |
|---|---|---|
INVALID_AMOUNT | Amount is zero, negative, or malformed | Validate amount before calling |
INVALID_ADDRESS | Wallet address format is invalid | Validate address format |
INVALID_TOKEN | Token address not recognized | Use address from strategy |
Business Logic Errors (4xx)
| Code | Description | Recommended Action |
|---|---|---|
INSUFFICIENT_BALANCE | Wallet balance too low for operation | Show balance, suggest lower amount |
STRATEGY_NOT_ACTIVE | Strategy is paused or deprecated | Refresh venues, pick another |
ALLOCATION_NOT_FOUND | No position exists at this venue | Check allocations first |
OPERATION_EXPIRED | Unsigned transaction expired | Create new operation |
OPERATION_ALREADY_SUBMITTED | Transaction already submitted | Check operation status |
TOKEN_MISMATCH | Token doesn’t match strategy | Use tokenAddress from strategy |
INVALID_OPERATION_STATUS | Operation in wrong state for action | Check operation status first |
OPERATION_IN_PROGRESS | Another operation is executing for this wallet | Wait for it to complete, or cancel it |
Resource Errors (404)
| Code | Description | Recommended Action |
|---|---|---|
VENUE_NOT_FOUND | Venue ID doesn’t exist | Refresh venue list |
STRATEGY_NOT_FOUND | Strategy ID doesn’t exist | Refresh venue list |
OPERATION_NOT_FOUND | Operation ID doesn’t exist | May have been cleaned up |
TRANSACTION_NOT_FOUND | Transaction ID doesn’t exist | Check operation status |
WALLET_NOT_FOUND | Wallet not registered | Register the wallet first via wallets.register() |
ORGANIZATION_NOT_FOUND | API key’s org not found | Check API key |
TOKEN_NOT_FOUND | Token not supported | Check supported tokens |
Simulation Errors (4xx)
| Code | Description | Recommended Action |
|---|---|---|
INSUFFICIENT_GAS | Not enough SOL for transaction fee | Prompt user to add SOL |
SIMULATION_FAILED | Transaction simulation failed | Check error details |
Authentication Errors (401/403)
| Code | Description | Recommended Action |
|---|---|---|
INVALID_API_KEY | API key not recognized | Check API key configuration |
API_KEY_DISABLED | API key has been revoked | Contact support |
Rate Limiting (429)
| Code | Description | Recommended Action |
|---|---|---|
RATE_LIMIT_EXCEEDED | Too many requests | Implement backoff |
Network Errors
| Code | Description | Recommended Action |
|---|---|---|
TIMEOUT | Request timed out | Retry with backoff |
NETWORK_ERROR | Network connectivity issue | Check connection, retry |
UNKNOWN_ERROR | Unexpected error | Log and report |
Error Details by Code
Many errors include adetails object with structured context. Here are the fields returned for each error code:
| Error Code | Details Fields | Example |
|---|---|---|
INSUFFICIENT_BALANCE | requested: string, available: string | { "requested": "1000000", "available": "500000" } |
OPERATION_IN_PROGRESS | operationId: number, walletId: number | { "operationId": 123, "walletId": 45 } |
INSUFFICIENT_GAS | walletAddress: string, blockchain: string | { "walletAddress": "So11...abc", "blockchain": "solana" } |
SIMULATION_FAILED | logs?: string[], unitsConsumed?: number | { "logs": ["Program log: Error"], "unitsConsumed": 50000 } |
TOKEN_MISMATCH | expected: string, actual: string | { "expected": "USDC", "actual": "USDT" } |
STRATEGY_NOT_ACTIVE | strategyId: number | { "strategyId": 1 } |
ALLOCATION_NOT_FOUND | strategyId: number, walletAddress: string | { "strategyId": 1, "walletAddress": "So11...abc" } |
Transaction Failure Codes
When a transaction fails, check thefailureCode for details:
| Code | Description |
|---|---|
REVERTED | Smart contract execution reverted |
OUT_OF_GAS | Transaction ran out of gas |
TIMEOUT | Not included in block within timeout |
NONCE_TOO_LOW | Nonce already used (duplicate tx) |
INSUFFICIENT_FUNDS | Not enough native token for gas |
REPLACED | Transaction replaced by another |
DROPPED | Dropped from mempool |
UNKNOWN | Unknown failure reason |