# IrtError: cause property

> The cause read-only property of the IrtError interface is what the error wraps, such as an aborted signal's reason.

The **`cause`** read-only property of the [`IrtError`](/docs/client/irt-error) interface is what the error wraps: the reason an aborted `signal` carried, or the error of a request that didn't complete.

## Value

Any value, or `undefined` when the error wraps nothing. It's the `signal`'s `reason` for an `AbortError` or a `TimeoutError` that a `signal` caused, as `fetch()` rejects with it, and the failed `fetch()`'s error for a `NetworkError` from a room-wide request.

## Description

`cause` is the standard `Error` property. Branch on [`name`](/docs/client/irt-error/name) and [`code`](/docs/client/irt-error/code), and use `cause` to see what the game passed to `AbortController.abort()`.

## Examples

### Telling a cancel button from a timeout

The join screen aborts with a reason when the player cancels, so a game can tell the two apart.

```ts
// cancel-reason.ts
import { connect, IrtError } from "@irtio/client";

const joining = new AbortController();
document.querySelector("#cancel")?.addEventListener("click", () => joining.abort("cancelled"));

try {
  await connect("lobby", { signal: joining.signal });
} catch (e) {
  if (e instanceof IrtError && e.name === "AbortError") console.log(`stopped: ${String(e.cause)}`);
  else throw e;
}
```

## See also

- [`IrtError.name`](/docs/client/irt-error/name)
- [`connect()`](/docs/client/connect)
- [Errors and close codes](/docs/client/errors)
