Skip to main content

RebelfiError Class

All API errors are thrown as RebelfiError instances with structured information:

Properties

PropertyTypeDescription
messagestringHuman-readable error message
statusCodenumberHTTP status code
codeErrorCodeMachine-readable error code
detailsobjectAdditional error context

Checking Error Type

Use the .is() method to check for specific errors:

Error Codes

Validation Errors (4xx)

CodeDescriptionRecommended Action
INVALID_AMOUNTAmount is zero, negative, or malformedValidate amount before calling
INVALID_ADDRESSWallet address format is invalidValidate address format
INVALID_TOKENToken address not recognizedUse address from strategy

Business Logic Errors (4xx)

CodeDescriptionRecommended Action
INSUFFICIENT_BALANCEWallet balance too low for operationShow balance, suggest lower amount
STRATEGY_NOT_ACTIVEStrategy is paused or deprecatedRefresh venues, pick another
ALLOCATION_NOT_FOUNDNo position exists at this venueCheck allocations first
OPERATION_EXPIREDUnsigned transaction expiredCreate new operation
OPERATION_ALREADY_SUBMITTEDTransaction already submittedCheck operation status
TOKEN_MISMATCHToken doesn’t match strategyUse tokenAddress from strategy
INVALID_OPERATION_STATUSOperation in wrong state for actionCheck operation status first
OPERATION_IN_PROGRESSAnother operation is executing for this walletWait for it to complete, or cancel it

Resource Errors (404)

CodeDescriptionRecommended Action
VENUE_NOT_FOUNDVenue ID doesn’t existRefresh venue list
STRATEGY_NOT_FOUNDStrategy ID doesn’t existRefresh venue list
OPERATION_NOT_FOUNDOperation ID doesn’t existMay have been cleaned up
TRANSACTION_NOT_FOUNDTransaction ID doesn’t existCheck operation status
WALLET_NOT_FOUNDWallet not registeredRegister the wallet first via wallets.register()
ORGANIZATION_NOT_FOUNDAPI key’s org not foundCheck API key
TOKEN_NOT_FOUNDToken not supportedCheck supported tokens

Simulation Errors (4xx)

CodeDescriptionRecommended Action
INSUFFICIENT_GASNot enough SOL for transaction feePrompt user to add SOL
SIMULATION_FAILEDTransaction simulation failedCheck error details

Authentication Errors (401/403)

CodeDescriptionRecommended Action
INVALID_API_KEYAPI key not recognizedCheck API key configuration
API_KEY_DISABLEDAPI key has been revokedContact support

Rate Limiting (429)

CodeDescriptionRecommended Action
RATE_LIMIT_EXCEEDEDToo many requestsImplement backoff

Network Errors

CodeDescriptionRecommended Action
TIMEOUTRequest timed outRetry with backoff
NETWORK_ERRORNetwork connectivity issueCheck connection, retry
UNKNOWN_ERRORUnexpected errorLog and report

Error Details by Code

Many errors include a details object with structured context. Here are the fields returned for each error code:
Error CodeDetails FieldsExample
INSUFFICIENT_BALANCErequested: string, available: string{ "requested": "1000000", "available": "500000" }
OPERATION_IN_PROGRESSoperationId: number, walletId: number{ "operationId": 123, "walletId": 45 }
INSUFFICIENT_GASwalletAddress: string, blockchain: string{ "walletAddress": "So11...abc", "blockchain": "solana" }
SIMULATION_FAILEDlogs?: string[], unitsConsumed?: number{ "logs": ["Program log: Error"], "unitsConsumed": 50000 }
TOKEN_MISMATCHexpected: string, actual: string{ "expected": "USDC", "actual": "USDT" }
STRATEGY_NOT_ACTIVEstrategyId: number{ "strategyId": 1 }
ALLOCATION_NOT_FOUNDstrategyId: number, walletAddress: string{ "strategyId": 1, "walletAddress": "So11...abc" }

Transaction Failure Codes

When a transaction fails, check the failureCode for details:
CodeDescription
REVERTEDSmart contract execution reverted
OUT_OF_GASTransaction ran out of gas
TIMEOUTNot included in block within timeout
NONCE_TOO_LOWNonce already used (duplicate tx)
INSUFFICIENT_FUNDSNot enough native token for gas
REPLACEDTransaction replaced by another
DROPPEDDropped from mempool
UNKNOWNUnknown failure reason

Error Handling Patterns

Comprehensive Handler

Retry with Backoff

Operation Expiry Handling

Next Steps

TypeScript Reference

Complete type definitions

API Reference

REST API documentation