Errors
Errors
When a call cannot complete, the SDK throws NutrimaticError with a stable string code. Use code in your UI and logging to decide what to show the user (toast, disable a button, retry, or fix config) — do not parse message for branching; messages may change.
import { NutrimaticError } from '@nutrimatic/sdk'
try {
await sdk.easy.read.getChart({ pair: '42-USDT', interval: '1h' })
} catch (error) {
if (error instanceof NutrimaticError) {
// Branch on error.code — e.g. show "try again" vs "this action is unavailable"
console.error(error.code, error.message)
}
}Example — error shape
What you inspect after instanceof NutrimaticError:
{
"name": "NutrimaticError",
"code": "CAPABILITY_NOT_AVAILABLE",
"message": "staking.stake is not available."
}| Field | What to use it for |
|---|---|
code | Stable switch in UI / analytics (this is the contract). |
message | Human-readable detail for logs or optional secondary copy. |
name | Always NutrimaticError for instanceof checks. |
Common codes
| Code | Meaning |
|---|---|
INTEGRATION_CONTEXT_REQUIRED | Config is missing integrationContext ('client' or 'backend'). Set it when calling createNutrimaticSdk. |
INVALID_CONFIG | Config failed validation at init (e.g. duplicate ledger id / alias, empty ledgers). Fix config and recreate the SDK. |
INFRASTRUCTURE_UNAVAILABLE | Nutrimatic could not reach its service, or the operation could not complete. Retry later or check connectivity. |
READ_ONLY_MODE | A write was called but the SDK was created with mode: 'read'. Use 'full' when your app runs writes — Modes. |
CAPABILITY_NOT_AVAILABLE | The operation is not available for this config or request. Do not retry like a network timeout. |
LEDGER_NOT_SUPPORTED | The ledger is not in your config, or the LedgerScope string did not match any configured id or alias. |
VENUE_NOT_FOUND | The venue ID you passed does not match any known pool. |
PAIR_NOT_FOUND | The pair label you passed does not resolve to a known market. |
INSTRUMENT_NOT_FOUND | The instrument ID (or symbol) you passed does not resolve. |
MANIFEST_NOT_FOUND | No deployment manifest is available for this ledger. |
NORMALIZATION_FAILED | Nutrimatic could not normalize the underlying data into a display-ready shape. |
WALLET_REQUIRED | A wallet was needed (signing, or omitted owner on a portfolio read) and none was configured — Whose wallet (owner). |
Do not branch on MODULE_NOT_IMPLEMENTED — it is unused.
When to use which code
These codes are easy to confuse. Branch on them like this:
| You see… | What it means | What to do |
|---|---|---|
READ_ONLY_MODE | You called a write after init with mode: 'read' | Recreate with 'full' and a wallet — Modes |
WALLET_REQUIRED | Signing or default owner needs a WalletAdapter | Pass wallet, or pass owner explicitly on reads |
LEDGER_NOT_SUPPORTED | Ledger / scope is missing or does not resolve in your config | Fix ledgers or the LedgerScope you passed |
PAIR_NOT_FOUND / INSTRUMENT_NOT_FOUND / VENUE_NOT_FOUND | Lookup key does not resolve | Fix the pair label, instrument id, or venue id |
INFRASTRUCTURE_UNAVAILABLE | Service unreachable, or a read path could not complete | Retry / check connectivity — may be transient |
CAPABILITY_NOT_AVAILABLE | This action is not available for this config or request | Disable or hide the action; do not retry as if it were infra |
Write codes
| Code | Meaning |
|---|---|
USER_REJECTED | The user (or adapter) declined to sign. |
QUOTE_EXPIRED | The quote’s expiresAt passed, or the sign request expired before execution. |
SLIPPAGE_EXCEEDED | The market moved beyond the allowed slippageBps (bps) before the trade could settle. |
INSUFFICIENT_ALLOWANCE | Your wallet’s approved spend allowance is too low to cover this operation. |
Write overview: Write operations.