Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.argyros.xyz/llms.txt

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

Error Handling

The SDK throws typed errors for different failure conditions. All errors extend ArgyrosError.

Error Hierarchy

ArgyrosError (base)
├── BadRequestError    (400)
├── AuthError          (401/403)
├── NoRouteError       (404)
├── RateLimitError     (429)
└── ServerError        (5xx)

Error Classes

ArgyrosError

Base class for all SDK errors.
PropertyTypeDescription
messagestringError message
statusCodenumberHTTP status code
bodyunknownRaw response body from the API

BadRequestError (400)

Thrown for invalid parameters: bad mint address, invalid amount, unsupported swap mode.
import { BadRequestError } from "@argyros/sdk";

try {
  await sdk.quote({ inputMint: "invalid", ... });
} catch (err) {
  if (err instanceof BadRequestError) {
    console.log(err.message); // "invalid inputMint address"
  }
}

AuthError (401/403)

Thrown when the API key is invalid, missing, or revoked.
import { AuthError } from "@argyros/sdk";

try {
  await sdk.quote({ ... });
} catch (err) {
  if (err instanceof AuthError) {
    console.log(err.message); // "Invalid or missing API key"
  }
}

NoRouteError (404)

Thrown when no liquidity path exists between the input and output tokens.
import { NoRouteError } from "@argyros/sdk";

try {
  await sdk.quote({ ... });
} catch (err) {
  if (err instanceof NoRouteError) {
    console.log("No route found -- try a different token pair");
  }
}

RateLimitError (429)

Thrown after all retry attempts are exhausted on rate-limited requests.
import { RateLimitError } from "@argyros/sdk";

try {
  await sdk.quote({ ... });
} catch (err) {
  if (err instanceof RateLimitError) {
    console.log("Rate limited -- back off and retry later");
  }
}

ServerError (5xx)

Thrown after all retry attempts are exhausted on server errors.
import { ServerError } from "@argyros/sdk";

try {
  await sdk.quote({ ... });
} catch (err) {
  if (err instanceof ServerError) {
    console.log("Server error -- retry later");
  }
}

Retry Behavior

The SDK automatically retries on transient failures before throwing:
StatusRetriedError thrown after exhaustion
400noBadRequestError (immediate)
401/403noAuthError (immediate)
404noNoRouteError (immediate)
429yesRateLimitError
5xxyesServerError
Network error / timeoutyesError
Backoff is exponential: 1s, 2s, 4s, … capped at 8s. With the default retries: 2, the SDK makes up to 3 attempts.

Catching All Errors

import {
  ArgyrosSDK,
  ArgyrosError,
  NoRouteError,
  RateLimitError,
  AuthError,
  BadRequestError,
  ServerError,
} from "@argyros/sdk";

try {
  const quote = await sdk.quote({ ... });
} catch (err) {
  if (err instanceof NoRouteError) {
    // No liquidity path
  } else if (err instanceof BadRequestError) {
    // Invalid parameters
  } else if (err instanceof AuthError) {
    // Bad API key
  } else if (err instanceof RateLimitError) {
    // Rate limited after retries
  } else if (err instanceof ServerError) {
    // Server error after retries
  } else if (err instanceof ArgyrosError) {
    // Other API error
    console.log(err.statusCode, err.message);
  } else {
    // Network error, timeout, etc.
  }
}