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 both the error code and the agent, for example [AGENT_NOT_FOUND][agent:zyfai] ....
Convenience subclasses
| Class | Code | Notes |
|---|---|---|
AgentNotFoundError | AGENT_NOT_FOUND | Message: Unknown agent "<agentId>". Available agents: <agents> |
NotConnectedError | NOT_CONNECTED | Message: "Not connected. Call sdk.connect(provider) first." |
AgentChainIncompatibleError | AGENT_CHAIN_INCOMPATIBLE | Extra 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"
| "AGENT_DISABLED"
| "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"
| "WITHDRAW_FAILED"
| "API_ROUTING_ERROR"
| "API_ROUTING_FAILED"
| "API_NO_AGENTS"
| "SPONSOR_REQUEST_FAILED"
| "BALANCE_ALL_FAILED"
| "ALLOCATION_ALL_FAILED"
| "VALIDATION_INVALID_DAYS";
Code reference
| Code | Meaning |
|---|---|
NOT_CONNECTED | Wallet-dependent method called before connect(). |
NO_ACTIVE_CHAIN | Method called before activateAgent(). |
WALLET_NO_ACCOUNTS | Provider returned no accounts during connect(). |
WALLET_ADDRESS_REQUIRED | Wallet address was missing during agent auth. |
AGENT_NOT_FOUND | Unknown agent ID was passed. |
AGENT_CHAIN_INCOMPATIBLE | One or more selected agents do not support the requested chain. |
AGENT_EMPTY_LIST | An empty agentId array was passed to activateAgent(). |
AGENT_DISABLED | A disabled agent was explicitly selected for activation or deposit. |
CHAIN_UNSUPPORTED | Chain ID is not in the supported list. |
CHAIN_NO_COMPATIBLE_AGENTS | No agents support the requested chain. |
ASSET_UNSUPPORTED | The selected agent does not support the asset on the active chain. |
ASSET_NO_COMPATIBLE_AGENTS | No agents support the asset on the active chain. |
DEPOSIT_AMOUNT_BELOW_MINIMUM | Deposit amount is below an agent minimum. |
DEPOSIT_CALLBACK_REQUIRED | A callback was required by an underlying deposit path but was not provided. |
DEPOSIT_CALLBACK_INVALID | depositCallback did not return a tx hash. |
DEPOSIT_NO_PERMITTED_TOKENS | No permitted deposit tokens were available. |
WITHDRAW_NO_PERMITTED_TOKENS | No permitted withdrawal tokens were available. |
WITHDRAW_INSUFFICIENT_BALANCE | Requested withdrawal exceeds total available balance. |
WITHDRAW_ALL_FAILED | All eligible agent withdrawals failed. |
WITHDRAW_PARTIAL_FAILURE | Some withdrawals succeeded, but the full requested amount could not be completed. |
WITHDRAW_FAILED | An underlying agent withdrawal attempt failed. |
API_ROUTING_ERROR | Routing API returned a non-OK HTTP status. |
API_ROUTING_FAILED | Routing API returned success: false. |
API_NO_AGENTS | The routing API returned no supported agents. |
SPONSOR_REQUEST_FAILED | Sponsored deposit request failed (network error or non-success sponsor API response). |
BALANCE_ALL_FAILED | All active-agent balance requests failed. |
ALLOCATION_ALL_FAILED | All active-agent allocation inputs failed. |
VALIDATION_INVALID_DAYS | An invalid APY lookback value was provided. |