Skip to main content
PraxaClient throws a PraxaClientError for every HTTP error response it receives from the gateway. This is the only error type the SDK itself raises for API failures — all other thrown values (such as TypeError for network connectivity issues or DOMException for aborted requests) originate from the underlying fetch implementation. Because PraxaClientError extends the native Error class, you can use a standard instanceof check in any catch block to distinguish API errors from unexpected exceptions.

PraxaClientError

PraxaClientError carries two pieces of structured information alongside the inherited message string:
The Problem type looks like this:
Use instanceof PraxaClientError to safely narrow the type and access status and problem:

Common Error Status Codes

Automatic Retries

The SDK silently retries requests that return a retryable status code, as long as the request is safe to replay. The retryable status codes are: 408, 425, 429, 500, 502, 503, and 504. A request is eligible for retry when it either:
  • Carries an idempotency key (e.g. createMission, signalMission, cancelMission), or
  • Is a safe read (all GET requests and searchCapabilities / queryMemory).
The SDK performs up to maximumAttempts total attempts (default 3, maximum 4) with exponential backoff: before attempt n it waits retryBaseDelayMs × 2^(n-1) milliseconds. The idempotency key is preserved unchanged on every retry so the gateway can detect and discard duplicates.
Once all attempts are exhausted, the SDK throws the final PraxaClientError for your code to handle.

Non-Retryable Errors

The following status codes indicate a client-side problem that retrying will not fix. The SDK throws immediately without any retry:
  • 400 Bad Request — the request payload is structurally invalid.
  • 401 Unauthorized — the access token is missing or expired.
  • 403 Forbidden — the token lacks the required OAuth scope.
  • 404 Not Found — the requested resource does not exist.
  • 409 Conflict — an idempotency key conflict was detected.
You must handle these errors explicitly in your application code. For 401 specifically, refresh the token and resubmit. For 400 and 409, inspect err.problem to understand exactly what went wrong before attempting again.
Check err.problem?.type for machine-readable error classification. The type field is a URI that uniquely identifies the error class — for example, "https://praxa.ai/problems/invalid-goal-spec" or "https://praxa.ai/problems/budget-exceeded". You can use it in a lookup table or switch statement to drive automated recovery logic without parsing human-readable strings.