---
url: https://lit-ui-router.dev/api/ui-router-effect/functions/errorRef.md
---
[ui-router-effect](../index.md) / errorRef

# Function: errorRef()

```ts
function errorRef(router): SubscriptionRef<Rejection | undefined>;
```

Defined in: [ui-router-effect/src/transition-refs.ts:80](https://github.com/simshanith/lit-ui-router/blob/244ec1323549ff0c5b191b1bc747eea4668acdc4/packages/ui-router-effect/src/transition-refs.ts#L80)

The failed-transition ref for a router — one per router instance,
attached lazily, sharing [pendingRef](pendingRef.md)'s `onStart` hook.

It holds the newest transition's failure as core's `Rejection`, and
`undefined` otherwise. Only a `RejectType.ERROR` rejection, such as a
resolve that throws, sets it; superseded, redirected, aborted and ignored
transitions leave it `undefined`, as does a success. The next transition
clears it as it starts, and a superseded transition that fails late never
sets it. Kept out of `RouteSnapshot`.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `router` | [`UIRouter`](https://ui-router.github.io/core/docs/latest/classes/_router_.uirouter.html) |

## Returns

[`SubscriptionRef`](https://effect.website/docs/state-management/subscriptionref/)<`Rejection` | `undefined`>
