|
5 | 5 | Applications running in Node.js will generally experience four categories of
|
6 | 6 | errors:
|
7 | 7 |
|
8 |
| -- JavaScript errors caused by improper JavaScript language syntax |
9 |
| - ([`SyntaxError`][]), use of undefined variables ([`ReferenceError`][]), |
10 |
| - passing arguments of the wrong type ([`TypeError`][]), and so on; |
| 8 | +- Standard JavaScript errors such as: |
| 9 | + - [`EvalError`][]: thrown when a call to `eval()` fails. |
| 10 | + - [`SyntaxError`][]: thrown in response to improper JavaScript language |
| 11 | + syntax. |
| 12 | + - [`RangeError`][]: thrown when a value is not within an expected range |
| 13 | + - [`ReferenceError`][]: thrown when using undefined variables |
| 14 | + - [`TypeError`][]: thrown when passing arguments of the wrong type |
| 15 | + - [`URIError`][]: thrown when a global URI handling function is misused. |
11 | 16 | - System errors triggered by underlying operating system constraints such
|
12 | 17 | as attempting to open a file that does not exist, attempting to send data
|
13 | 18 | over a closed socket, etc;
|
@@ -87,7 +92,9 @@ Errors that occur within _Asynchronous APIs_ may be reported in multiple ways:
|
87 | 92 |
|
88 | 93 | - A handful of typically asynchronous methods in the Node.js API may still
|
89 | 94 | use the `throw` mechanism to raise exceptions that must be handled using
|
90 |
| - `try / catch`. |
| 95 | + `try / catch`. There is no comprehensive list of such methods; please |
| 96 | + refer to the documentation of each method to determine the appropriate |
| 97 | + error handling mechanism required. |
91 | 98 |
|
92 | 99 | The use of the `'error'` event mechanism is most common for [stream-based][]
|
93 | 100 | and [event emitter-based][] APIs, which themselves represent a series of
|
@@ -155,7 +162,7 @@ use `throw` inside a Node.js style callback:
|
155 | 162 | });
|
156 | 163 | } catch(err) {
|
157 | 164 | // This will not catch the throw!
|
158 |
| - console.log(err); // Error: ENOENT |
| 165 | + console.log(err); |
159 | 166 | }
|
160 | 167 |
|
161 | 168 | This will not work because the callback function passed to `fs.readFile()` is
|
|
0 commit comments