diff --git a/lib/console.js b/lib/console.js index 642ef209d6b975..6358a3e19d4b08 100644 --- a/lib/console.js +++ b/lib/console.js @@ -151,11 +151,10 @@ Console.prototype.timeEnd = function timeEnd(label) { Console.prototype.trace = function trace(...args) { - // TODO probably can to do this better with V8's debug object once that is - // exposed. - var err = new Error(); - err.name = 'Trace'; - err.message = util.format.apply(null, args); + const err = { + name: 'Trace', + message: util.format.apply(null, args) + }; Error.captureStackTrace(err, trace); this.error(err.stack); }; diff --git a/lib/internal/errors.js b/lib/internal/errors.js index fcfbdd24bf3925..5ada4cb7f40f67 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -28,7 +28,6 @@ function makeNodeError(Base) { constructor(key, ...args) { super(message(key, args)); this[kCode] = key; - Error.captureStackTrace(this, NodeError); } get name() {