# Errors

> Every exception the SDK throws.

Source: https://docs.stxapp.io/sdks/typescript/reference/errors/

{/* Generated from the TypeScript source by tools/gen-reference.mjs. Do not edit by hand. */}

Every exception extends `STXException`. Catch the class you care about with `instanceof`.

| Exception | Extends | When |
|---|---|---|
| [`STXException`](#stxexception) | `Error` | Base for every error the SDK throws. |
| [`STXConfigException`](#stxconfigexception) | `STXException` | The client is misconfigured: unknown region, missing key, bad PEM. |
| [`STXAPIException`](#stxapiexception) | `STXException` | The API answered with an error status. Base for the classes below. |
| [`STXValidationException`](#stxvalidationexception) | `STXAPIException` | 400: a parameter or body field was rejected, e.g. `price is required`. |
| [`STXAuthenticationException`](#stxauthenticationexception) | `STXAPIException` | 401: the signature, key ID or timestamp was not accepted. A machine clock more than 30 seconds off also lands here. |
| [`STXForbiddenException`](#stxforbiddenexception) | `STXAPIException` | 403: the key is read-only, or the account may not do this. When the server names the scopes that would satisfy the call (in the `WWW-Authenticate` challenge), `requiredScopes` lists them. |
| [`STXNotFoundException`](#stxnotfoundexception) | `STXAPIException` | 404: the resource does not exist, or belongs to another account. |
| [`STXRejectedException`](#stxrejectedexception) | `STXAPIException` | 422: the exchange refused the request, e.g. insufficient funds or a closed market. |
| [`STXGeoLocationException`](#stxgeolocationexception) | `STXRejectedException` | 422 from the exchange's geo-fencing: this request's IP address is not allowed to trade, or the geolocation packet sent with it was missing, invalid, expired or from another user. A subclass of `STXRejectedException`, so existing `catch` blocks still see it. |
| [`STXRateLimitException`](#stxratelimitexception) | `STXAPIException` | 429: too many requests. `retryAfter` is seconds, when sent. |
| [`STXServerException`](#stxserverexception) | `STXAPIException` | 5xx: the server failed. Retried by the default policy on GET and DELETE. |
| [`STXTransportException`](#stxtransportexception) | `STXException` | The request never got an answer: connection, DNS, TLS or timeout. |
| [`STXChannelException`](#stxchannelexception) | `STXException` | A channel join or channel message was refused by the server. `reply` holds the server's `response` object, for example `{reason: "unauthorized"}`. |
| [`STXTimeoutException`](#stxtimeoutexception) | `STXChannelException` | No reply, message or snapshot arrived on a channel in time. A subclass of `STXChannelException`. |

## `STXException`

Base for every error the SDK throws.

| Property | Type | Description |
|---|---|---|
| `body` | `unknown` |  |
| `method` | `string \| undefined` |  |
| `path` | `string \| undefined` |  |
| `statusCode` | `number \| undefined` |  |

## `STXConfigException`

The client is misconfigured: unknown region, missing key, bad PEM.

## `STXAPIException`

The API answered with an error status. Base for the classes below.

## `STXValidationException`

400: a parameter or body field was rejected, e.g. `price is required`.

## `STXAuthenticationException`

401: the signature, key ID or timestamp was not accepted. A machine clock
more than 30 seconds off also lands here.

## `STXForbiddenException`

403: the key is read-only, or the account may not do this. When the server
names the scopes that would satisfy the call (in the `WWW-Authenticate`
challenge), `requiredScopes` lists them.

| Property | Type | Description |
|---|---|---|
| `requiredScopes` | `readonly string[]` |  |

## `STXNotFoundException`

404: the resource does not exist, or belongs to another account.

## `STXRejectedException`

422: the exchange refused the request, e.g. insufficient funds or a closed
market.

## `STXGeoLocationException`

422 from the exchange's geo-fencing: this request's IP address is not
allowed to trade, or the geolocation packet sent with it was missing,
invalid, expired or from another user. A subclass of
`STXRejectedException`, so existing `catch` blocks still see it.

`reason` classifies it; `ipAddress` is the address the exchange saw, when
its message names one. Never retried.

| Property | Type | Description |
|---|---|---|
| `ipAddress` | `string \| undefined` |  |
| `reason` | `"ip_not_allowed" \| "packet_invalid" \| "packet_other_user" \| "packet_ip_mismatch" \| "location_not_allowed"` |  |

## `STXRateLimitException`

429: too many requests. `retryAfter` is seconds, when sent.

| Property | Type | Description |
|---|---|---|
| `retryAfter` | `number \| undefined` |  |

## `STXServerException`

5xx: the server failed. Retried by the default policy on GET and DELETE.

## `STXTransportException`

The request never got an answer: connection, DNS, TLS or timeout.

## `STXChannelException`

A channel join or channel message was refused by the server. `reply` holds
the server's `response` object, for example `{reason: "unauthorized"}`.

| Property | Type | Description |
|---|---|---|
| `reply` | `unknown` |  |
| `topic` | `string` |  |

## `STXTimeoutException`

No reply, message or snapshot arrived on a channel in time. A subclass of
`STXChannelException`.
