> ## Documentation Index
> Fetch the complete documentation index at: https://docs.useunitpay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Error handling

> The SDK's typed error model

Every request throws a typed error you can discriminate with `instanceof`. All extend `UnitPayError`.

## Usage

```tsx theme={null}
import { HttpError, NetworkError, TimeoutError } from '@unitpay/react';

try {
  await client.get('/customers/cus_123');
} catch (e) {
  if (e instanceof HttpError && e.isAuthError) {
    // 401 / 403 — redirect to sign-in
  } else if (e instanceof HttpError && e.isRateLimited) {
    // 429 — back off (the client already honors Retry-After)
  } else if (e instanceof TimeoutError) {
    // exceeded the configured timeout
  } else if (e instanceof NetworkError) {
    // offline / DNS / TLS
  }
}
```

## Error types

### `HttpError`

A non-2xx response. Carries `status`, `code`, `requestId`, and `details`, plus convenience getters:

<ParamField body="isAuthError" type="boolean">
  `true` for `401` / `403`.
</ParamField>

<ParamField body="isRateLimited" type="boolean">
  `true` for `429`.
</ParamField>

<ParamField body="isRetryable" type="boolean">
  `true` for `408` / `429` / `5xx`. The client retries these automatically with jittered exponential backoff.
</ParamField>

### `NetworkError`

A failed fetch — offline, DNS, or TLS error. Carries the underlying `cause`.

### `TimeoutError`

The request exceeded the configured timeout.

### `PmInUseError`

Thrown by `usePaymentMethods().detach()` when the card is still in use. Carries `activeSubscriptionIds` and `autoTopupAccountIds` so you can tell the customer what's blocking removal — pair it with [`usePaymentMethodDependencies`](/react/payment-methods) to show the blockers before they try.

<Note>
  Transient failures (`408` / `429` / `5xx` and network errors) are retried automatically with
  jittered exponential backoff. Retry budget and per-request timeout are configurable on the client.
</Note>
