---
title: "Errors"
description: "Every failure throws, with the same two classes as `@nextmail/sdk`."
url: "https://nextmail.sh/docs/mailbox/errors"
area: "Client"
category: "Getting started"
---

# Errors

Every failure throws, with the same two classes as `@nextmail/sdk`.

## Catching one

**catch-errors.ts**

```
import { NextmailApiError, NextmailNetworkError } from '@nextmail/mailbox'

try {
  await client.emails.send(message)
} catch (error) {
  if (error instanceof NextmailApiError) {
    if (error.isPermission) console.error('this person or app cannot do that')
    if (error.isRateLimited) console.error('try again in', error.retryAfterSeconds, 'seconds')

    console.error(error.status, error.requestId)
  }

  if (error instanceof NextmailNetworkError && error.isTimeout) console.error('no answer in time')

  throw error
}
```

A `permission_error` means the person cannot reach that address or thread, or their approval of your app does not cover it. Check what they can send from with `client.addresses.list()`.
