Base error class for all O2 Exchange errors.

All API errors extend this class. Check code for pre-flight errors and reason for on-chain revert details.

try {
await client.createOrder("fFUEL/fUSDC", "buy", "0.02", "100");
} catch (error) {
if (error instanceof O2Error) {
console.log(error.code, error.message, error.reason);
}
}

Hierarchy (View Summary)

Constructors

  • Parameters

    • message: string
    • Optionalcode: number
    • Optionalreason: string
    • Optionalreceipts: unknown[]

    Returns O2Error

Properties

cause?: unknown
code: undefined | number

API error code (present for pre-flight validation errors).

message: string
name: string
reason: undefined | string

On-chain revert reason string (e.g., "NotEnoughBalance").

receipts: undefined | unknown[]

Transaction receipts from on-chain reverts.

stack?: string