Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ostium.com/llms.txt

Use this file to discover all available pages before exploring further.

The SDK exposes two error classes:
  • OstiumError for client creation, transaction building, signing, submission, and contract interaction
  • OstiumSubgraphError for subgraph reads, builder API reads, parsing, and stream-related data lookups

OstiumError

OstiumError is thrown by the main OstiumClient surface.
import { OstiumError, OstiumErrorCode } from '@ostium/builder-sdk';

try {
  await client.openTrade(params);
} catch (error) {
  if (error instanceof OstiumError) {
    console.error(error.code, error.message);
  }
}

Error codes

CodeMeaning
INVALID_CONFIGThe client was created with incompatible or missing configuration for the selected mode.
VALIDATION_FAILEDInput parameters failed SDK validation before submission.
ALLOWANCE_INSUFFICIENTThe trader does not have enough USDC allowance for the requested action.
SUBMISSION_FAILEDTransaction or user operation submission failed.
DELEGATION_FAILEDDelegation setup is missing or the requested delegated action is not allowed in the current mode.
CONTRACT_ERRORA contract read or write failed.
NETWORK_ERRORAn RPC or network request failed.

OstiumSubgraphError

OstiumSubgraphError is thrown by read methods backed by the subgraph or builder API.
import { OstiumSubgraphError, OstiumSubgraphErrorCode } from '@ostium/builder-sdk';

try {
  const positions = await client.getOpenPositions({ user: '0xTraderAddress' });
} catch (error) {
  if (error instanceof OstiumSubgraphError) {
    console.error(error.code, error.message);
  }
}

Error codes

CodeMeaning
INVALID_CONFIGThe read client was created with invalid endpoint or mode configuration.
INVALID_PARAMSThe read method was called with invalid arguments.
FETCH_FAILEDThe subgraph or builder API request failed.
NOT_FOUNDA requested entity or pair could not be found.
PARSE_ERRORThe SDK received data but could not parse it into the expected shape.
  • Catch OstiumError around trade setup and write methods.
  • Catch OstiumSubgraphError around read methods and streams.
  • Log both error.code and error.message.
  • If present, inspect error.cause for the underlying RPC, contract, or fetch error.