# IrtError: code property

> The code read-only property of the IrtError interface is the close code, HTTP status or other number behind the error.

The **`code`** read-only property of the [`IrtError`](/docs/client/irt-error) interface is the number behind the error: a close code, an HTTP status or 0 when there was none.

## Value

A number, one of:

4000 to 4099
: The router or the room closed the connection with this close code, one the client doesn't reconnect after. The `CloseCode` export names them, and [Close codes](/docs/client/errors#close-codes) lists each one's causes.

1000
: [`close()`](/docs/client/room-client/close) was called before the client was ready.

422
: A call the room answered with an error, such as a handler that threw [`CallRejected`](/docs/room/call-rejected), or args that don't match the call's fields.

400 to 599
: [`createRoom()`](/docs/client/createroom), [`joinByCode()`](/docs/client/joinbycode), [`listPublic()`](/docs/client/listpublic) or [`quickJoin()`](/docs/client/quickjoin) failed with this HTTP status.

0
: There was no close code: the router couldn't be reached, a timeout passed, a `signal` aborted, a call got no answer from the room or the client was used before it was ready or after it closed.

## Description

`code` is the detail behind [`name`](/docs/client/irt-error/name). Use it where one name covers several causes, such as `InvalidStateError`, which is both 4011, a room that hibernated by its own request, and 4012, the same player connecting elsewhere. `IrtError` isn't a `DOMException`, whose own numeric `code` means something else.

## Examples

### Offering a rejoin after the room hibernated

A room that asks to hibernate with players connected closes their connections with 4011. The client doesn't reconnect after it, so the game offers a button that connects again, which wakes the room.

```ts
// rejoin.ts
import { CloseCode, type ReadyRoomClient } from "@irtio/client";

export function offerRejoin(room: ReadyRoomClient, rejoin: () => void) {
  room.addEventListener("close", ({ error }) => {
    if (error?.code !== CloseCode.RoomHibernated) return;
    const button = document.createElement("button");
    button.textContent = "Rejoin";
    button.addEventListener("click", rejoin, { once: true });
    document.body.append(button);
  });
}
```

## See also

- [`IrtError.name`](/docs/client/irt-error/name)
- [Close codes](/docs/client/errors#close-codes)
- [`Room.hibernate()`](/docs/room/room/hibernate)
