Skip to content

Commit

Permalink
lib: refactor ERR_SYNTHETIC
Browse files Browse the repository at this point in the history
- Tidy up description in docs.
- Remove a second definition in the docs.
- Remove unused string input parameter.
- Remove duplicate "JavaScript Callstack" in error messages.

PR-URL: #25749
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
cjihrig authored and addaleax committed Jan 30, 2019
1 parent 6967407 commit 99bc0df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
10 changes: 2 additions & 8 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1692,8 +1692,8 @@ length.
<a id="ERR_SYNTHETIC"></a>
#### ERR_SYNTHETIC

An artificial error object used to capture call stack when diagnostic report
is produced.
An artificial error object used to capture the call stack for diagnostic
reports.

<a id="ERR_SYSTEM_ERROR"></a>
### ERR_SYSTEM_ERROR
Expand Down Expand Up @@ -2227,12 +2227,6 @@ size.
This `Error` is thrown when a read is attempted on a TTY `WriteStream`,
such as `process.stdout.on('data')`.

<a id="ERR_SYNTHETIC"></a>
#### ERR_SYNTHETIC

An artifical error object used to capture call stack when diagnostic report
is produced.


[`'uncaughtException'`]: process.html#process_event_uncaughtexception
[`--force-fips`]: cli.html#cli_force_fips
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ E('ERR_STREAM_UNSHIFT_AFTER_END_EVENT',
'stream.unshift() after end event', Error);
E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode', Error);
E('ERR_STREAM_WRITE_AFTER_END', 'write after end', Error);
E('ERR_SYNTHETIC', 'JavaScript Callstack: %s', Error);
E('ERR_SYNTHETIC', 'JavaScript Callstack', Error);
E('ERR_SYSTEM_ERROR', 'A system error occurred', SystemError);
E('ERR_TLS_CERT_ALTNAME_INVALID',
'Hostname/IP does not match certificate\'s altnames: %s', Error);
Expand Down
8 changes: 3 additions & 5 deletions lib/internal/process/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,11 @@ exports.setup = function() {
emitExperimentalWarning('report');
if (err == null) {
if (file == null) {
return nr.triggerReport(new ERR_SYNTHETIC(
'JavaScript Callstack').stack);
return nr.triggerReport(new ERR_SYNTHETIC().stack);
}
if (typeof file !== 'string')
throw new ERR_INVALID_ARG_TYPE('file', 'String', file);
return nr.triggerReport(file, new ERR_SYNTHETIC(
'JavaScript Callstack').stack);
return nr.triggerReport(file, new ERR_SYNTHETIC().stack);
}
if (typeof err !== 'object')
throw new ERR_INVALID_ARG_TYPE('err', 'Object', err);
Expand All @@ -120,7 +118,7 @@ exports.setup = function() {
getReport(err) {
emitExperimentalWarning('report');
if (err == null) {
return nr.getReport(new ERR_SYNTHETIC('JavaScript Callstack').stack);
return nr.getReport(new ERR_SYNTHETIC().stack);
} else if (typeof err !== 'object') {
throw new ERR_INVALID_ARG_TYPE('err', 'Objct', err);
} else {
Expand Down

0 comments on commit 99bc0df

Please sign in to comment.