# Error reference

Every error JSPrismarine throws has a code and an entry in this reference. When the server logs an
error, the last line names its code and links to the entry:


```text
More about PRISMARINE_PLAYER_NOT_FOUND: https://jsprismarine.dev/errors/prismarine/server#prismarine-player-not-found
```


Code that embeds the server or uses a package on its own reads the same two values from the error
it catches, as `error.code` and `error.docs`.

There are 1416 errors, one page per package. A package that throws many, such as
`@jsprismarine/prismarine`, has a page per catalog module as well, which its page lists:


| Package                                                       | Errors |
| ------------------------------------------------------------- | ------ |
| [`@jsprismarine/addon-tools`](https://jsprismarine.dev/errors/addon-tools.md)                 | 17     |
| [`@jsprismarine/auth`](https://jsprismarine.dev/errors/auth.md)                               | 26     |
| [`@jsprismarine/binaryutils`](https://jsprismarine.dev/errors/binaryutils.md)                 | 6      |
| [`@jsprismarine/block-behaviors`](https://jsprismarine.dev/errors/block-behaviors.md)         | 1      |
| [`@jsprismarine/blocks`](https://jsprismarine.dev/errors/blocks.md)                           | 15     |
| [`@jsprismarine/brigadier`](https://jsprismarine.dev/errors/brigadier.md)                     | 7      |
| [`@jsprismarine/chunkgen`](https://jsprismarine.dev/errors/chunkgen.md)                       | 33     |
| [`@jsprismarine/client`](https://jsprismarine.dev/errors/client.md)                           | 43     |
| [`@jsprismarine/commands`](https://jsprismarine.dev/errors/commands.md)                       | 26     |
| [`@jsprismarine/errors`](https://jsprismarine.dev/errors/common.md)                           | 1      |
| [`@jsprismarine/console-protocol`](https://jsprismarine.dev/errors/console-protocol.md)       | 1      |
| [`@jsprismarine/console`](https://jsprismarine.dev/errors/console.md)                         | 17     |
| [`@jsprismarine/content`](https://jsprismarine.dev/errors/content.md)                         | 15     |
| [`@jsprismarine/engine-systems`](https://jsprismarine.dev/errors/engine-systems.md)           | 1      |
| [`@jsprismarine/entities`](https://jsprismarine.dev/errors/entities.md)                       | 1      |
| [`@jsprismarine/entity-brains`](https://jsprismarine.dev/errors/entity-brains.md)             | 5      |
| [`@jsprismarine/entity-goals`](https://jsprismarine.dev/errors/entity-goals.md)               | 1      |
| [`@jsprismarine/features`](https://jsprismarine.dev/errors/features.md)                       | 53     |
| [`@jsprismarine/items`](https://jsprismarine.dev/errors/items.md)                             | 5      |
| [`@jsprismarine/kernel`](https://jsprismarine.dev/errors/kernel.md)                           | 13     |
| [`@jsprismarine/leveldb`](https://jsprismarine.dev/errors/leveldb.md)                         | 69     |
| [`@jsprismarine/lighting`](https://jsprismarine.dev/errors/lighting.md)                       | 4      |
| [`@jsprismarine/loot`](https://jsprismarine.dev/errors/loot.md)                               | 6      |
| [`@jsprismarine/management-protocol`](https://jsprismarine.dev/errors/management-protocol.md) | 3      |
| [`@jsprismarine/mapping`](https://jsprismarine.dev/errors/mapping.md)                         | 1      |
| [`@jsprismarine/minecraft`](https://jsprismarine.dev/errors/minecraft.md)                     | 1      |
| [`@jsprismarine/molang`](https://jsprismarine.dev/errors/molang.md)                           | 11     |
| [`@jsprismarine/native-library`](https://jsprismarine.dev/errors/native-library.md)           | 10     |
| [`@jsprismarine/native-network`](https://jsprismarine.dev/errors/native-network.md)           | 8      |
| [`@jsprismarine/native-worldgen`](https://jsprismarine.dev/errors/native-worldgen.md)         | 11     |
| [`@jsprismarine/nbt`](https://jsprismarine.dev/errors/nbt.md)                                 | 38     |
| [`@jsprismarine/nethernet`](https://jsprismarine.dev/errors/nethernet.md)                     | 42     |
| [`@jsprismarine/packs`](https://jsprismarine.dev/errors/packs.md)                             | 38     |
| [`@jsprismarine/predicates`](https://jsprismarine.dev/errors/predicates.md)                   | 2      |
| [`@jsprismarine/prismarine`](https://jsprismarine.dev/errors/prismarine.md)                   | 438    |
| [`@jsprismarine/protocol`](https://jsprismarine.dev/errors/protocol.md)                       | 152    |
| [`@jsprismarine/raknet`](https://jsprismarine.dev/errors/raknet.md)                           | 30     |
| [`@jsprismarine/script-host`](https://jsprismarine.dev/errors/script-host.md)                 | 89     |
| [`@jsprismarine/server`](https://jsprismarine.dev/errors/server.md)                           | 23     |
| [`@jsprismarine/structures`](https://jsprismarine.dev/errors/structures.md)                   | 43     |
| [`@jsprismarine/worldgen`](https://jsprismarine.dev/errors/worldgen.md)                       | 110    |


## Reading an entry

An entry's heading is the error's code, such as `PRISMARINE_PLAYER_NOT_FOUND`. Below it is the message,
with each value the error fills in written as a name in braces: the message
`Player "{username}" not found.` reaches the log as `Player "Steve" not found.`.

Next comes the class to catch the error by. Most errors extend `Error`, `TypeError` or
`RangeError`, as the code threw before the reference existed. Some extend a group class instead,
such as `CorruptionError` in `@jsprismarine/leveldb`, so one `instanceof` check catches every error
of that kind. A package's page lists its groups first. When the code explains what causes an error
and what to do about it, that explanation follows.

## Adding an error

The errors live in `@jsprismarine/errors`, one catalog per package, and code throws them from
there. Its README explains how to add one, and the lint fails on a `new Error(...)` anywhere else.
