> For the complete documentation index, see [llms.txt](https://obytejs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://obytejs.com/client/subscribe-to-errors.md).

# Subscribe to errors

### Example

```javascript
const client = new obyte.Client('wss://obyte.org/bb', {
  reconnect: true,
  closeIfError: true,
});

client.onError(function(err) {
  console.error('WebSocket error:', err.message);
});
```

### Returns

```javascript
WebSocket error: boom
```

When `closeIfError: true` is set, the client disables reconnect and closes the socket on the first WebSocket error.

```js
client.client.reconnect;
// false after the error
```
