···11+# Runtime errors
22+33+There are several runtime errors that Gleam code can throw. This documentation
44+lists them and their runtime properties.
55+66+On Erlang runtime errors are Erlang maps thrown with `erlang:error/1`, having at
77+least these properties:
88+99+| Key | Type | Value |
1010+| --- | ---- | ----- |
1111+| gleam_error | Atom | See individual errors |
1212+| message | String | See individual errors |
1313+| module | String | The module the error occured in |
1414+| function | String | The function the error occured in |
1515+| line | Int | The line number the error occured on |
1616+1717+On JavaScript runtime errors are instances of the JavaScript `Error` class,
1818+having at least these properties added to them:
1919+2020+| Key | Type | Value |
2121+| --- | ---- | ----- |
2222+| gleam_error | String | See individual errors |
2323+| message | String | See individual errors |
2424+| module | String | The module the error occured in |
2525+| function | String | The function the error occured in |
2626+| line | Number | The line number the error occured on |
2727+2828+## Todo
2929+3030+A panic that indicates that the code has not yet been completed, intended for
3131+use in development.
3232+3333+```gleam
3434+todo
3535+todo as "some message"
3636+```
3737+| Key | Erlang Value | JavaScript Value |
3838+| --- | ------------ | ---------------- |
3939+| gleam_error | `todo` | `"todo"` |
4040+| message | The given message | The given message |
4141+4242+## Panic
4343+4444+An explicit panic to unconditionally error.
4545+4646+```gleam
4747+panic
4848+panic as "some message"
4949+```
5050+| Key | Erlang Value | JavaScript Value |
5151+| --- | ------------ | ---------------- |
5252+| gleam_error | `panic` | `"panic"` |
5353+| message | The given message | The given message |
5454+5555+## Let assert
5656+5757+An inexhaustive pattern match, erroring if the pattern does not match.
5858+5959+```gleam
6060+let assert Ok(x) = something()
6161+6262+```
6363+| Key | Erlang Value | JavaScript Value |
6464+| --- | ------------ | ---------------- |
6565+| gleam_error | `let_assert` | `"let_assert"` |
6666+| message | The given message | The given message |
6767+| value | The unmatched value | The unmatched value |