SdkError
The main error type returned by SDK functions.Result Type
SdkResult<T> which is an alias for Result<T, SdkError>.
Common Error Variants
Network Errors
Rpc
RPC client errors from Solana.
- Network connectivity issues
- RPC endpoint errors
- Transaction simulation failures
Ws
WebSocket connection errors.
Grpc
gRPC connection errors.
Data Errors
InvalidAccount
The account data is not a valid Drift account.
InvalidOracle
The oracle account is invalid or not supported.
Deserializing
Failed to deserialize account data.
NoPosition
User does not have a position in the specified market.
NoMarketData
Market data not available - need to subscribe to the market.
NoAccountData
Account data not available.
Transaction Errors
OutOfSOL
Insufficient SOL balance for transaction fees or rent.
Signing
Error signing transaction.
WalletSigningDisabled
Attempted to sign with a read-only wallet.
Math Errors
MathError
Mathematical operation error (overflow, underflow, division by zero).
Subscription Errors
AlreadySubscribed
Attempted to subscribe when already subscribed.
CouldntUnsubscribe
Failed to unsubscribe from updates.
MissedHeartbeat
DLOB heartbeat was missed.
Connection Errors
MaxReconnectionAttemptsReached
Exhausted reconnection attempts.
WebsocketError
Generic WebSocket error.
Other Errors
Generic
Generic error with custom message.
InvalidSeed
Invalid keypair seed provided.
JitOrderNotFound
JIT taker order not found.
Error Handling Methods
to_anchor_error_code
Extract Drift program error code from RPC error.
Some(ProgramError) if the error contains a Drift program error
Example:
to_out_of_sol_error
Convert to OutOfSOL error if applicable.
ProgramError
Represents errors from the Drift program.Drift(ErrorCode)- Error from Drift programOther { ix_idx, code }- Error from another program in the transaction