Skip to main content

Errors

The Owney SDK throws OwneyError instances for SDK-level failures. Convenience subclasses are provided for common cases, but all public SDK errors share the same code, optional details, and optional agentId fields.

OwneyError

class OwneyError extends Error {
readonly code: OwneyErrorCode;
readonly details?: Record<string, unknown>;
readonly agentId?: string;
}

When agentId is set, error.message is prefixed with [agent:<id>].

Convenience subclasses

ClassCodeNotes
AgentNotFoundErrorAGENT_NOT_FOUNDMessage: Unknown agent "<agentId>". Available agents: <agents>
NotConnectedErrorNOT_CONNECTEDMessage: "Not connected. Call sdk.connect(provider) first."
AgentChainIncompatibleErrorAGENT_CHAIN_INCOMPATIBLEExtra properties: incompatibleAgents, connectedChainId

Error codes

type OwneyErrorCode =
| "NOT_CONNECTED"
| "NO_ACTIVE_CHAIN"
| "WALLET_NO_ACCOUNTS"
| "WALLET_ADDRESS_REQUIRED"
| "AGENT_NOT_FOUND"
| "AGENT_CHAIN_INCOMPATIBLE"
| "AGENT_EMPTY_LIST"
| "CHAIN_UNSUPPORTED"
| "CHAIN_NO_COMPATIBLE_AGENTS"
| "ASSET_UNSUPPORTED"
| "ASSET_NO_COMPATIBLE_AGENTS"
| "DEPOSIT_AMOUNT_BELOW_MINIMUM"
| "DEPOSIT_CALLBACK_REQUIRED"
| "DEPOSIT_CALLBACK_INVALID"
| "DEPOSIT_NO_PERMITTED_TOKENS"
| "WITHDRAW_NO_PERMITTED_TOKENS"
| "WITHDRAW_INSUFFICIENT_BALANCE"
| "WITHDRAW_ALL_FAILED"
| "WITHDRAW_PARTIAL_FAILURE"
| "API_ROUTING_ERROR"
| "API_ROUTING_FAILED"
| "API_SAIL_ERROR"
| "API_SAIL_TIMEOUT"
| "API_NO_AGENTS"
| "BALANCE_ALL_FAILED"
| "ALLOCATION_ALL_FAILED"
| "VALIDATION_INVALID_DAYS";

Code reference

CodeMeaning
NOT_CONNECTEDWallet-dependent method called before connect().
NO_ACTIVE_CHAINMethod called before activateAgent().
WALLET_NO_ACCOUNTSProvider returned no accounts during connect().
WALLET_ADDRESS_REQUIREDWallet address was missing during agent auth.
AGENT_NOT_FOUNDUnknown agent ID was passed.
AGENT_CHAIN_INCOMPATIBLEOne or more selected agents do not support the requested chain.
AGENT_EMPTY_LISTAn empty agentId array was passed to activateAgent().
CHAIN_UNSUPPORTEDChain ID is not in the supported list.
CHAIN_NO_COMPATIBLE_AGENTSNo agents support the requested chain.
ASSET_UNSUPPORTEDThe selected agent does not support the asset on the active chain.
ASSET_NO_COMPATIBLE_AGENTSNo agents support the asset on the active chain.
DEPOSIT_AMOUNT_BELOW_MINIMUMDeposit amount is below an agent minimum.
DEPOSIT_CALLBACK_REQUIREDA deposit was attempted without depositCallback.
DEPOSIT_CALLBACK_INVALIDdepositCallback did not return a tx hash.
DEPOSIT_NO_PERMITTED_TOKENSNo permitted deposit tokens were available.
WITHDRAW_NO_PERMITTED_TOKENSNo permitted withdrawal tokens were available.
WITHDRAW_INSUFFICIENT_BALANCERequested withdrawal exceeds total available balance.
WITHDRAW_ALL_FAILEDAll eligible agent withdrawals failed.
WITHDRAW_PARTIAL_FAILURESome withdrawals succeeded, but the full requested amount could not be completed.
API_ROUTING_ERRORRouting API returned a non-OK HTTP status.
API_ROUTING_FAILEDRouting API returned success: false.
API_SAIL_ERRORSail API returned a non-OK HTTP status.
API_SAIL_TIMEOUTSail API request timed out.
API_NO_AGENTSThe routing API returned no supported agents.
BALANCE_ALL_FAILEDAll active-agent balance requests failed.
ALLOCATION_ALL_FAILEDAll active-agent allocation inputs failed.
VALIDATION_INVALID_DAYSAn invalid APY lookback value was provided.