|
4 | 4 |
|
5 | 5 | <!--type=misc-->
|
6 | 6 |
|
7 |
| -Applications running in Node.js will generally experience four categories of |
8 |
| -errors: |
| 7 | +Applications running in Node.js will generally experience the following |
| 8 | +categories of errors: |
9 | 9 |
|
10 | 10 | * Standard JavaScript errors such as {EvalError}, {SyntaxError}, {RangeError},
|
11 | 11 | {ReferenceError}, {TypeError}, and {URIError}.
|
| 12 | +* Standard `DOMException`s. |
12 | 13 | * System errors triggered by underlying operating system constraints such
|
13 | 14 | as attempting to open a file that does not exist or attempting to send data
|
14 | 15 | over a closed socket.
|
15 |
| -* User-specified errors triggered by application code. |
16 | 16 | * `AssertionError`s are a special class of error that can be triggered when
|
17 | 17 | Node.js detects an exceptional logic violation that should never occur. These
|
18 | 18 | are raised typically by the `node:assert` module.
|
| 19 | +* User-specified errors triggered by application code. |
19 | 20 |
|
20 | 21 | All JavaScript and system errors raised by Node.js inherit from, or are
|
21 | 22 | instances of, the standard JavaScript {Error} class and are guaranteed
|
22 | 23 | to provide _at least_ the properties available on that class.
|
23 | 24 |
|
| 25 | +The [`error.message`][] property of errors raised by Node.js may be changed in |
| 26 | +any versions. Use [`error.code`][] to identify an error instead. For a |
| 27 | +`DOMException`, use [`domException.name`][] to identify its type. |
| 28 | + |
24 | 29 | ## Error propagation and interception
|
25 | 30 |
|
26 | 31 | <!--type=misc-->
|
@@ -4303,7 +4308,10 @@ An error occurred trying to allocate memory. This should never happen.
|
4303 | 4308 | [`dgram.createSocket()`]: dgram.md#dgramcreatesocketoptions-callback
|
4304 | 4309 | [`dgram.disconnect()`]: dgram.md#socketdisconnect
|
4305 | 4310 | [`dgram.remoteAddress()`]: dgram.md#socketremoteaddress
|
| 4311 | +[`domException.name`]: https://developer.mozilla.org/en-US/docs/Web/API/DOMException/name |
4306 | 4312 | [`errno`(3) man page]: https://man7.org/linux/man-pages/man3/errno.3.html
|
| 4313 | +[`error.code`]: #errorcode |
| 4314 | +[`error.message`]: #errormessage |
4307 | 4315 | [`fs.Dir`]: fs.md#class-fsdir
|
4308 | 4316 | [`fs.cp()`]: fs.md#fscpsrc-dest-options-callback
|
4309 | 4317 | [`fs.readFileSync`]: fs.md#fsreadfilesyncpath-options
|
|
0 commit comments