diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 2a162f14b24206..c3ccbaf0f08a9a 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -134,12 +134,10 @@ function lazyBuffer() { // and may have .path and .dest. class SystemError extends Error { constructor(key, context) { - if (excludedStackFn === undefined) { - super(); - } else { + super(); + if (excludedStackFn !== undefined) { const limit = Error.stackTraceLimit; Error.stackTraceLimit = 0; - super(); // Reset the limit and setting the name property. Error.stackTraceLimit = limit; } @@ -251,12 +249,10 @@ function makeSystemErrorWithCode(key) { function makeNodeErrorWithCode(Base, key) { return class NodeError extends Base { constructor(...args) { - if (excludedStackFn === undefined) { - super(); - } else { + super(); + if (excludedStackFn !== undefined) { const limit = Error.stackTraceLimit; Error.stackTraceLimit = 0; - super(); // Reset the limit and setting the name property. Error.stackTraceLimit = limit; }