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

# Handle errors

> Catch every SDK error in one place and branch on its kind, status or error code.

export const waitlists = {
  earlyAccess: "",
  payments: "",
  openBanking: "",
  developers: "",
  verifiers: ""
};

<Note>
  **Private preview:** this is rolling out and may not be available on your account yet.{waitlists.earlyAccess ? <> <a href={waitlists.earlyAccess}>Request early access →</a></> : null}
</Note>

Every error the SDK throws or returns extends one base class. Catch with `isSumvinError`, then narrow.

```ts theme={null}
import { isApiError, isContractDriftError, isSumvinError, unwrap } from "@sumvin/sdk";

try {
  const identities = unwrap(await listAgentIdentities({ client }));
} catch (e) {
  if (!isSumvinError(e)) throw e;

  if (isApiError(e)) {
    console.error(e.kind, e.status, e.errorCode);
  } else if (isContractDriftError(e)) {
    console.error(e.operationKey, e.reason);
  }
}
```

| Guard                  | Means                                                                                   |
| ---------------------- | --------------------------------------------------------------------------------------- |
| `isApiError`           | The request failed: the API answered with an error, or the network or transport failed. |
| `isContractDriftError` | The API answered, but the response didn't match the shape the SDK expects.              |

The two never overlap, so check `isSumvinError` first and then each one.

## Kinds of request failure

`ApiError.kind` is one of:

| Kind               | Means                                                                             |
| ------------------ | --------------------------------------------------------------------------------- |
| `problem`          | The API returned an error body with an error code. Read `errorCode` and `status`. |
| `http`             | An HTTP error with no error body. Read `status`.                                  |
| `network`          | The request never got an answer.                                                  |
| `abort`            | The request was cancelled or timed out.                                           |
| `redirect-refused` | The API answered with a redirect, which the SDK refuses.                          |

## Branch on codes, not messages

`message` is a diagnostic for developers. Build what your users see from `errorCode`, `status` and `kind`. The codes are listed in [Errors](/reference/errors).
