diff --git a/lib/internal/process/report.js b/lib/internal/process/report.js index 50ddc8c4b379a5..141a150a715555 100644 --- a/lib/internal/process/report.js +++ b/lib/internal/process/report.js @@ -91,13 +91,13 @@ const report = { }, getReport(err) { emitExperimentalWarning('report'); - if (err == null) { - return nr.getReport(new ERR_SYNTHETIC().stack); - } else if (typeof err !== 'object') { + + if (err === undefined) + err = new ERR_SYNTHETIC(); + else if (err === null || typeof err !== 'object') throw new ERR_INVALID_ARG_TYPE('err', 'Object', err); - } else { - return nr.getReport(err.stack); - } + + return nr.getReport(err.stack); } };