# Handle errors

A failed request rejects with a plain object carrying a `code`, not an `Error`.

```js title="Read the error code"
try {
  await subbly.cart.addItem({ productId: 3301 })
} catch (error) {
  if (error.code === 'out_of_stock') {
    // tell the customer
  }
}
```

The full list of codes is on the
[Subbly.js SDK reference](/reference/subbly-sdk#errors).
