# onError: Unavailability reasons and failures

> STEP 3-2

```ts
onError?: (error: { kind: string }) => void
```

The SDK does not throw exceptions. Instead, it reports why Checkout+ is unavailable, and failures, through this callback. The value passed in is `{ kind: string }`, and the `kind` names are listed in the table below. More names may be added in the future. In every case, checkout is not blocked.

| Situation | `kind` | Banner | What the SDK user does |
| --- | --- | --- | --- |
| In the options passed to `init()`, `storeId` or `cart` is invalid ([conditions](./shopify-headless-reference-init.html#exceptions-and-failures)) | `invalid-options` | Not shown | Check the values you pass to `init()` |
| There is no benefit set (the commitment charge and benefits for each range). The `metafield` returned by `getCart` is `null` (the benefit set is not set up yet, a wrong metafield namespace or key, and so on) | `not-published` | Not shown, and not shown again on that page | Check the metafield namespace and key. If they are correct, contact Recustomer |
| The cart cannot be fetched. `CartConnector`'s `getCart` threw an exception | `unavailable` | Not shown, and not shown again on that page | Send it to your monitoring system |
| The benefit set format is invalid | `invalid-benefit-set` | Not shown, and not shown again on that page | Nothing. Recustomer fixes the benefit set |
| Checkout+ acceptance is suspended | `acceptance-suspended` | Not shown. Decided again on the next `refresh()` | Nothing if you receive it in production. If you receive it during development, check in the Recustomer admin dashboard that the Checkout+ status is 「受付中」 (Accepting) ([Getting started](../checkout-plus/activation.html)) |
| The cart currency differs from the benefit set's currency | `currency-not-offered` | Not shown. Decided again on the next `refresh()` | Nothing |
| A cart amount is empty or negative | `invalid-cart` | Not shown, and not shown again on that page | Check that `CartConnector` returns values that follow the specification |
| The product tags are unknown. A line returned by `getCart` has no `tags` field | `invalid-cart` | Not shown, and not shown again on that page | Check that `getCart` returns `tags` on every line. For a product without tags, return an empty array `[]` |
| The values returned by `CartConnector` are malformed | `invalid-cart` | Not shown, and not shown again on that page | Check that `CartConnector` returns values that follow the specification |
| Adding the Checkout+ product was rejected | `add-failed` | Shown | Send it to your monitoring system, and contact Recustomer |
| Removing the Checkout+ product was rejected, and the SDK could not confirm that it was removed | `remove-failed` | Shown | Send it to your monitoring system. If it continues, check that `updateCheckoutPlusLines` updates the same cart that `getCart` returns, and that it removes lines using the line IDs returned by `getCart` as is |
| An unexpected failure occurred inside the UI components (the banner or the details dialog) | `ui-failure` | Not shown | Contact Recustomer |
| An exception was thrown inside a callback (`onCheckoutPlusLinesChange`, etc.) | `callback-failure` | Drawn as usual when there is a target and the cart is eligible | Fix the callback code |

- With `invalid-options` and `ui-failure`, the SDK ends up in the same state as after calling `destroy()`. With `ui-failure`, checkout continues, but if an update was already sent, whether Checkout+ was attached is unknown. You can check it in the checkout or order line items.
- When it's "not shown again on that page", later calls to `refresh()` on that page complete without doing anything. The banner is shown again only when the page reloads, or when you start over from `init()` after `destroy()` ([What the SDK does for each trigger](./shopify-headless-behavior.html#what-the-sdk-does-for-each-trigger)).
- `onError` receives only the `kind`, not why `getCart` failed. If `unavailable` continues, check the exception that occurred inside your `getCart`.
- `invalid-options`, `invalid-cart`, and `callback-failure` are integration errors.
- The conditions for reporting `add-failed` and `remove-failed` are described in [When it returns `'rejected'`](./shopify-headless-reference-update-checkout-plus-lines.html#when-it-returns-rejected) for `updateCheckoutPlusLines`. Each is reported at most once per `CheckoutPlusSession`.
- When `remove-failed` arrives, the shopper may be proceeding to checkout with a Checkout+ product they did not select, or one for the previous range, still in the cart.

The following cases are not errors, so they are not reported through `onError`.

| Case | What the SDK does |
| --- | --- |
| The shopper unchecked the box | A normal selection. The banner is shown with the box unchecked |
| The banner is not shown for a cart with only excluded products, a cart with no matching range, and so on (the second ③ row in [What the SDK does for each trigger](./shopify-headless-behavior.html#what-the-sdk-does-for-each-trigger)) | A normal state. The banner is simply not shown |
| The result of adding the Checkout+ product in `prepareCheckout()` is unknown (for example, `updateCheckoutPlusLines` threw, or 10 seconds passed) | The addition was not necessarily rejected, so `add-failed` is not reported. Unless the SDK can confirm the product was added, checkout proceeds without Checkout+ |

```ts
// Pass this in the options of init(). Example: send it to your existing monitoring system (Sentry, Datadog, etc.)
onError: (error) => reportError(error),
```

## When it throws

- How the SDK handles it: The SDK keeps running. This exception is not reported to `onError` again.
- If it returns a Promise: The SDK does not wait for it to complete and does not receive a rejection. Handle failures of asynchronous work inside the callback.
