@kagamidigital/salt-sdk-mirror
    Preparing search index...

    Class ApiError

    Thrown when an API request returns a non-ok HTTP status.

    Surfaces the parsed response body so callers can inspect .code and .message (e.g. code INSUFFICIENT_FUNDS for insufficient-gas style failures) without losing the raw response.

    When the API returns a 403 status, an InsufficientPermissions instance is returned instead, indicating the caller lacks the required permissions for the requested action.

    import { ApiError, InsufficientPermissions } from 'salt-sdk';

    try {
    const account = await salt.getAccount('account-id');
    } catch (err) {
    // Check the subclass first — InsufficientPermissions is also an ApiError
    if (err instanceof InsufficientPermissions) {
    console.error('You do not have access to this account');
    } else if (err instanceof ApiError) {
    console.error(`${err.method} ${err.url} failed (${err.status})`, err.code);
    } else {
    throw err;
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • status: number
      • Optionalbody: unknown
      • Optionalurl: string
      • Optionalmethod: string

      Returns ApiError

    Properties

    body?: unknown

    The full parsed JSON response body, when available.

    code?: string

    Application error code from the response body, if present. E.g. "INSUFFICIENT_FUNDS", "CALL_EXCEPTION".

    message: string
    method?: string

    The HTTP method (e.g. GET, POST), when available.

    name: string
    stack?: string
    status: number

    HTTP status code (e.g. 500, 404).

    url?: string

    The request URL, when available.