Skip to content

Commit cc253b5

Browse files
cjihrigaddaleax
authored andcommitted
process: simplify report uncaught exception logic
This commit combines two if statements into a single if statement. Another if statement is replaced with a ternary. PR-URL: #25744 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent 454278a commit cc253b5

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lib/internal/process/execution.js

+8-13
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,14 @@ function createFatalException() {
105105
if (er == null || er.domain == null) {
106106
try {
107107
const report = internalBinding('report');
108-
if (report != null) {
109-
if (require('internal/options').getOptionValue(
110-
'--experimental-report')) {
111-
const config = {};
112-
report.syncConfig(config, false);
113-
if (Array.isArray(config.events) &&
114-
config.events.includes('exception')) {
115-
if (er) {
116-
report.onUnCaughtException(er.stack);
117-
} else {
118-
report.onUnCaughtException(undefined);
119-
}
120-
}
108+
if (report != null &&
109+
require('internal/options')
110+
.getOptionValue('--experimental-report')) {
111+
const config = {};
112+
report.syncConfig(config, false);
113+
if (Array.isArray(config.events) &&
114+
config.events.includes('exception')) {
115+
report.onUnCaughtException(er ? er.stack : undefined);
121116
}
122117
}
123118
} catch {} // NOOP, node_report unavailable.

0 commit comments

Comments
 (0)