# RoomCloseEvent: error property

> The error read-only property of the RoomCloseEvent interface is the IrtError that ended the connection, unless the client closed it itself.

The **`error`** read-only property of the [`RoomCloseEvent`](/docs/client/room-close-event) interface is the [`IrtError`](/docs/client/irt-error) that ended the connection, unless the client closed it itself.

## Value

An `IrtError` or `undefined`.

- On a [`close` event](/docs/client/room-client/close-event), it's the `IrtError` that ended the connection, with the close code as its `code`, or 0 when the first connection failed before any close. It's `undefined` when the client closed with [`close()`](/docs/client/room-client/close), when [`wasClean`](/docs/client/room-close-event/wasclean) is `true`.
- On a [`reconnecting` event](/docs/client/room-client/reconnecting-event), it's always `undefined`.

## Description

The error's [`name`](/docs/client/irt-error/name) is one of the web's error names, such as `VersionError` for 4004 or `TimeoutError` when the first connection took longer than `timeout`. When the client closes before it was ready, [`connect()`](/docs/client/connect) and [`ready`](/docs/client/room-client/ready) reject with the same error.

## Examples

### Reloading for a new build

A room build whose schema differs from the client's closes the connection with 4004, a `VersionError`. Reloading the page fetches the client that matches it.

```ts
// new-build.ts
import { connect, reloadForNewBuild } from "@irtio/client";

const room = await connect("https://rooms.irt.io/my-game/arena");

room.addEventListener("close", ({ error }) => {
  if (error?.name === "VersionError") reloadForNewBuild();
  else if (error) console.error(`${error.name}: ${error.message}`);
});
```

Reload only on `VersionError`. The client already reconnects after the codes that allow it.

## See also

- [`IrtError`](/docs/client/irt-error)
- [`reloadForNewBuild()`](/docs/client/reloadfornewbuild)
- [Errors and close codes](/docs/client/errors), for every name and code
