@@ -36,8 +36,8 @@ called.
36
36
37
37
All JavaScript errors are handled as exceptions that * immediately* generate
38
38
and throw an error using the standard JavaScript ` throw ` mechanism. These
39
- are handled using the [ ` try / catch ` construct] [ try-catch ] provided by the JavaScript
40
- language.
39
+ are handled using the [ ` try / catch ` construct] [ try-catch ] provided by the
40
+ JavaScript language.
41
41
42
42
``` js
43
43
// Throws with a ReferenceError because z is undefined
@@ -105,8 +105,8 @@ pass or fail).
105
105
106
106
For * all* ` EventEmitter ` objects, if an ` 'error' ` event handler is not
107
107
provided, the error will be thrown, causing the Node.js process to report an
108
- unhandled exception and crash unless either: The [ ` domain ` ] [ domains ] module is used
109
- appropriately or a handler has been registered for the
108
+ unhandled exception and crash unless either: The [ ` domain ` ] [ domains ] module is
109
+ used appropriately or a handler has been registered for the
110
110
[ ` process.on('uncaughtException') ` ] [ ] event.
111
111
112
112
``` js
@@ -255,15 +255,23 @@ will affect any stack trace captured *after* the value has been changed.
255
255
If set to a non-number value, or set to a negative number, stack traces will
256
256
not capture any frames.
257
257
258
- ### error.message
258
+ #### error.code
259
+
260
+ * {string}
261
+
262
+ The ` error.code ` property is a string label that identifies the kind of error.
263
+ See [ Node.js Error Codes] [ ] for details about specific codes.
264
+
265
+ #### error.message
259
266
260
267
* {string}
261
268
262
- The ` error.message ` property is the string description of the error as set by calling ` new Error(message) ` .
263
- The ` message ` passed to the constructor will also appear in the first line of
264
- the stack trace of the ` Error ` , however changing this property after the
265
- ` Error ` object is created * may not* change the first line of the stack trace
266
- (for example, when ` error.stack ` is read before this property is changed).
269
+ The ` error.message ` property is the string description of the error as set by
270
+ calling ` new Error(message) ` . The ` message ` passed to the constructor will also
271
+ appear in the first line of the stack trace of the ` Error ` , however changing
272
+ this property after the ` Error ` object is created * may not* change the first
273
+ line of the stack trace (for example, when ` error.stack ` is read before this
274
+ property is changed).
267
275
268
276
``` js
269
277
const err = new Error (' The message' );
@@ -451,18 +459,18 @@ added properties.
451
459
452
460
* {string}
453
461
454
- The ` error.code ` property is a string representing the error code, which is always
455
- ` E ` followed by a sequence of capital letters.
462
+ The ` error.code ` property is a string representing the error code, which is
463
+ typically ` E ` followed by a sequence of capital letters.
456
464
457
465
#### error.errno
458
466
459
467
* {string|number}
460
468
461
469
The ` error.errno ` property is a number or a string.
462
- The number is a ** negative** value which corresponds to the error code defined in
463
- [ ` libuv Error handling ` ] . See uv-errno.h header file ( ` deps/uv/include/uv-errno.h ` in
464
- the Node.js source tree) for details.
465
- In case of a string, it is the same as ` error.code ` .
470
+ The number is a ** negative** value which corresponds to the error code defined
471
+ in [ ` libuv Error handling ` ] . See uv-errno.h header file
472
+ ( ` deps/uv/include/uv-errno.h ` in the Node.js source tree) for details. In case
473
+ of a string, it is the same as ` error.code ` .
466
474
467
475
#### error.syscall
468
476
@@ -474,22 +482,22 @@ The `error.syscall` property is a string describing the [syscall][] that failed.
474
482
475
483
* {string}
476
484
477
- When present (e.g. in ` fs ` or ` child_process ` ), the ` error.path ` property is a string
478
- containing a relevant invalid pathname.
485
+ When present (e.g. in ` fs ` or ` child_process ` ), the ` error.path ` property is a
486
+ string containing a relevant invalid pathname.
479
487
480
488
#### error.address
481
489
482
490
* {string}
483
491
484
- When present (e.g. in ` net ` or ` dgram ` ), the ` error.address ` property is a string
485
- describing the address to which the connection failed.
492
+ When present (e.g. in ` net ` or ` dgram ` ), the ` error.address ` property is a
493
+ string describing the address to which the connection failed.
486
494
487
495
#### error.port
488
496
489
497
* {number}
490
498
491
- When present (e.g. in ` net ` or ` dgram ` ), the ` error.port ` property is a number representing
492
- the connection's port that is not available.
499
+ When present (e.g. in ` net ` or ` dgram ` ), the ` error.port ` property is a number
500
+ representing the connection's port that is not available.
493
501
494
502
### Common System Errors
495
503
@@ -550,6 +558,53 @@ found [here][online].
550
558
encountered by [ ` http ` ] [ ] or [ ` net ` ] [ ] -- often a sign that a ` socket.end() `
551
559
was not properly called.
552
560
561
+ <a id =" nodejs-error-codes " ></a >
562
+ ## Node.js Error Codes
563
+
564
+ <a id =" ERR_INVALID_ARG_TYPE " ></a >
565
+ ### ERR_INVALID_ARG_TYPE
566
+
567
+ The ` 'ERR_INVALID_ARG_TYPE' ` error code is used generically to identify that
568
+ an argument of the wrong type has been passed to a Node.js API.
569
+
570
+ <a id =" ERR_INVALID_CALLBACK " ></a >
571
+ ### ERR_INVALID_CALLBACK
572
+
573
+ The ` 'ERR_INVALID_CALLBACK' ` error code is used generically to identify that
574
+ a callback function is required and has not been provided to a Node.js API.
575
+
576
+ <a id =" ERR_STDERR_CLOSE " ></a >
577
+ ### ERR_STDERR_CLOSE
578
+
579
+ An error using the ` 'ERR_STDERR_CLOSE' ` code is thrown specifically when an
580
+ attempt is made to close the ` process.stderr ` stream. By design, Node.js does
581
+ not allow ` stdout ` or ` stderr ` Streams to be closed by user code.
582
+
583
+ <a id =" ERR_STDOUT_CLOSE " ></a >
584
+ ### ERR_STDOUT_CLOSE
585
+
586
+ An error using the ` 'ERR_STDOUT_CLOSE' ` code is thrown specifically when an
587
+ attempt is made to close the ` process.stdout ` stream. By design, Node.js does
588
+ not allow ` stdout ` or ` stderr ` Streams to be closed by user code.
589
+
590
+ <a id =" ERR_UNKNOWN_STDIN_TYPE " ></a >
591
+ ### ERR_UNKNOWN_STDIN_TYPE
592
+
593
+ An error using the ` 'ERR_UNKNOWN_STDIN_TYPE' ` code is thrown specifically when
594
+ an attempt is made to launch a Node.js process with an unknown ` stdin ` file
595
+ type. Errors of this kind cannot * typically* be caused by errors in user code,
596
+ although it is not impossible. Occurrences of this error are most likely an
597
+ indication of a bug within Node.js itself.
598
+
599
+ <a id =" ERR_UNKNOWN_STREAM_TYPE " ></a >
600
+ ### ERR_UNKNOWN_STREAM_TYPE
601
+
602
+ An error using the ` 'ERR_UNKNOWN_STREAM_TYPE' ` code is thrown specifically when
603
+ an attempt is made to launch a Node.js process with an unknown ` stdout ` or
604
+ ` stderr ` file type. Errors of this kind cannot * typically* be caused by errors
605
+ in user code, although it is not impossible. Occurrences of this error are most
606
+ likely an indication of a bug within Node.js itself.
607
+
553
608
[ `fs.readdir` ] : fs.html#fs_fs_readdir_path_options_callback
554
609
[ `fs.readFileSync` ] : fs.html#fs_fs_readfilesync_file_options
555
610
[ `fs.unlink` ] : fs.html#fs_fs_unlink_path_callback
@@ -562,6 +617,7 @@ found [here][online].
562
617
[ domains ] : domain.html
563
618
[ event emitter-based ] : events.html#events_class_eventemitter
564
619
[ file descriptors ] : https://en.wikipedia.org/wiki/File_descriptor
620
+ [ Node.js Error Codes ] : #nodejs-error-codes
565
621
[ online ] : http://man7.org/linux/man-pages/man3/errno.3.html
566
622
[ stream-based ] : stream.html
567
623
[ syscall ] : http://man7.org/linux/man-pages/man2/syscall.2.html
0 commit comments