From dc1d331403feb3b9d1ca1a2bd306ca7428414ed8 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 27 Jan 2019 16:03:14 -0500 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/25744 Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: Ruben Bridgewater Reviewed-By: Richard Lau --- lib/internal/process/execution.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index 74d6575e0a9114..4ee890e9db26d1 100644 --- a/lib/internal/process/execution.js +++ b/lib/internal/process/execution.js @@ -105,19 +105,14 @@ function createFatalException() { if (er == null || er.domain == null) { try { const report = internalBinding('report'); - if (report != null) { - if (require('internal/options').getOptionValue( - '--experimental-report')) { - const config = {}; - report.syncConfig(config, false); - if (Array.isArray(config.events) && - config.events.includes('exception')) { - if (er) { - report.onUnCaughtException(er.stack); - } else { - report.onUnCaughtException(undefined); - } - } + if (report != null && + require('internal/options') + .getOptionValue('--experimental-report')) { + const config = {}; + report.syncConfig(config, false); + if (Array.isArray(config.events) && + config.events.includes('exception')) { + report.onUnCaughtException(er ? er.stack : undefined); } } } catch {} // NOOP, node_report unavailable.