Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Document errors

+67
+67
docs/runtime-errors.md
··· 1 + # Runtime errors 2 + 3 + There are several runtime errors that Gleam code can throw. This documentation 4 + lists them and their runtime properties. 5 + 6 + On Erlang runtime errors are Erlang maps thrown with `erlang:error/1`, having at 7 + least these properties: 8 + 9 + | Key | Type | Value | 10 + | --- | ---- | ----- | 11 + | gleam_error | Atom | See individual errors | 12 + | message | String | See individual errors | 13 + | module | String | The module the error occured in | 14 + | function | String | The function the error occured in | 15 + | line | Int | The line number the error occured on | 16 + 17 + On JavaScript runtime errors are instances of the JavaScript `Error` class, 18 + having at least these properties added to them: 19 + 20 + | Key | Type | Value | 21 + | --- | ---- | ----- | 22 + | gleam_error | String | See individual errors | 23 + | message | String | See individual errors | 24 + | module | String | The module the error occured in | 25 + | function | String | The function the error occured in | 26 + | line | Number | The line number the error occured on | 27 + 28 + ## Todo 29 + 30 + A panic that indicates that the code has not yet been completed, intended for 31 + use in development. 32 + 33 + ```gleam 34 + todo 35 + todo as "some message" 36 + ``` 37 + | Key | Erlang Value | JavaScript Value | 38 + | --- | ------------ | ---------------- | 39 + | gleam_error | `todo` | `"todo"` | 40 + | message | The given message | The given message | 41 + 42 + ## Panic 43 + 44 + An explicit panic to unconditionally error. 45 + 46 + ```gleam 47 + panic 48 + panic as "some message" 49 + ``` 50 + | Key | Erlang Value | JavaScript Value | 51 + | --- | ------------ | ---------------- | 52 + | gleam_error | `panic` | `"panic"` | 53 + | message | The given message | The given message | 54 + 55 + ## Let assert 56 + 57 + An inexhaustive pattern match, erroring if the pattern does not match. 58 + 59 + ```gleam 60 + let assert Ok(x) = something() 61 + 62 + ``` 63 + | Key | Erlang Value | JavaScript Value | 64 + | --- | ------------ | ---------------- | 65 + | gleam_error | `let_assert` | `"let_assert"` | 66 + | message | The given message | The given message | 67 + | value | The unmatched value | The unmatched value |