# DanglingRefError

CLASS in `@skmtc/core 0.63.4`

Thrown when a reference that names nothing in the document is resolved:
no component has its name, it points outside the document (core does not
fetch), or its chain of `$ref`s comes back to one it
has passed (`A` is a `$ref` to `B`, and `B` to `A`), so it never reaches a
component.

By default the parser removes what holds such a reference, so a generator
never meets one. When `skmtc.config.json` `parse.danglingRefs` lists the
reference's kind, it stays, and a generator that resolves it can catch
this error and render something else in its place. Test for it with
`DanglingRefError.is`, not `instanceof`.

## Signature

```ts
import { DanglingRefError } from '@skmtc/core'

class DanglingRefError extends Error
```

## Constructor

### constructor

```ts
constructor(ref: string, args?: DanglingRefErrorOptions)
```

## Properties

- `ref` (string): The `$ref`, or the component name, that names nothing.
- `loop` (string[] | undefined): When the chain of `$ref`s loops: see `DanglingRefErrorOptions.loop`.

## Methods

### DanglingRefError.is

```ts
DanglingRefError.is(error: unknown): error is DanglingRefError
```

True when `error` is a `DanglingRefError`. It reads the error's name,
not its class, so it is also true for one thrown by another copy of
`@skmtc/core`, such as the copy a generator bundle resolves, where
`instanceof` is false.
