@@ -195,6 +195,8 @@ will either be instances of, or inherit from, the `Error` class.
195
195
196
196
### new Error(message)
197
197
198
+ * ` message ` {String}
199
+
198
200
Creates a new ` Error ` object and sets the ` error.message ` property to the
199
201
provided text message. If an object is passed as ` message ` , the text message
200
202
is generated by calling ` message.toString() ` . The ` error.stack ` property will
@@ -205,6 +207,9 @@ given by the property `Error.stackTraceLimit`, whichever is smaller.
205
207
206
208
### Error.captureStackTrace(targetObject[ , constructorOpt] )
207
209
210
+ * ` targetObject ` {Object}
211
+ * ` constructorOpt ` {Function}
212
+
208
213
Creates a ` .stack ` property on ` targetObject ` , which when accessed returns
209
214
a string representing the location in the code at which
210
215
` Error.captureStackTrace() ` was called.
@@ -238,6 +243,8 @@ new MyError().stack
238
243
239
244
### Error.stackTraceLimit
240
245
246
+ * {Number}
247
+
241
248
The ` Error.stackTraceLimit ` property specifies the number of stack frames
242
249
collected by a stack trace (whether generated by ` new Error().stack ` or
243
250
` Error.captureStackTrace(obj) ` ).
@@ -250,10 +257,13 @@ not capture any frames.
250
257
251
258
#### error.message
252
259
253
- Returns the string description of error as set by calling ` new Error(message) ` .
260
+ * {String}
261
+
262
+ The ` error.message ` property is the string description of the error as set by calling ` new Error(message) ` .
254
263
The ` message ` passed to the constructor will also appear in the first line of
255
264
the stack trace of the ` Error ` , however changing this property after the
256
- ` Error ` object is created * may not* change the first line of the stack trace.
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).
257
267
258
268
``` js
259
269
const err = new Error (' The message' );
@@ -263,8 +273,10 @@ console.log(err.message);
263
273
264
274
#### error.stack
265
275
266
- Returns a string describing the point in the code at which the ` Error ` was
267
- instantiated.
276
+ * {String}
277
+
278
+ The ` error.stack ` property is a string describing the point in the code at which
279
+ the ` Error ` was instantiated.
268
280
269
281
For example:
270
282
@@ -450,18 +462,47 @@ added properties.
450
462
451
463
#### error.code
452
464
453
- Returns a string representing the error code, which is always ` E ` followed by
454
- a sequence of capital letters, and may be referenced in ` man 2 intro ` .
465
+ * {String}
466
+
467
+ The ` error.code ` property is a string representing the error code, which is always
468
+ ` E ` followed by a sequence of capital letters.
455
469
456
470
#### error.errno
457
471
458
- Returns a number corresponding to the ** negated** error code, which may be
459
- referenced in ` man 2 intro ` . For example, an ` ENOENT ` error has an ` errno ` of
460
- ` -2 ` because the error code for ` ENOENT ` is ` 2 ` .
472
+ * {String | Number}
473
+
474
+ The ` error.errno ` property is a number or a string.
475
+ The number is a ** negative** value which corresponds to the error code defined in
476
+ [ ` libuv Error handling ` ] . See uv-errno.h header file (` deps/uv/include/uv-errno.h ` in
477
+ the Node.js source tree) for details.
478
+ In case of a string, it is the same as ` error.code ` .
461
479
462
480
#### error.syscall
463
481
464
- Returns a string describing the [ syscall] [ ] that failed.
482
+ * {String}
483
+
484
+ The ` error.syscall ` property is a string describing the [ syscall] [ ] that failed.
485
+
486
+ #### error.path
487
+
488
+ * {String}
489
+
490
+ When present (e.g. in ` fs ` or ` child_process ` ), the ` error.path ` property is a string
491
+ containing a relevant invalid pathname.
492
+
493
+ #### error.address
494
+
495
+ * {String}
496
+
497
+ When present (e.g. in ` net ` or ` dgram ` ), the ` error.address ` property is a string
498
+ describing the address to which the connection failed.
499
+
500
+ #### error.port
501
+
502
+ * {Number}
503
+
504
+ When present (e.g. in ` net ` or ` dgram ` ), the ` error.port ` property is a number representing
505
+ the connection's port that is not available.
465
506
466
507
### Common System Errors
467
508
@@ -528,6 +569,7 @@ found [here][online].
528
569
[ `fs` ] : fs.html
529
570
[ `http` ] : http.html
530
571
[ `https` ] : https.html
572
+ [ `libuv Error handling` ] : http://docs.libuv.org/en/v1.x/errors.html
531
573
[ `net` ] : net.html
532
574
[ `process.on('uncaughtException')` ] : process.html#process_event_uncaughtexception
533
575
[ domains ] : domain.html
0 commit comments