From 01bf93453f24bb113f6a055f2a8df7dc362bb3da Mon Sep 17 00:00:00 2001 From: Alexander Makarenko Date: Mon, 9 May 2016 00:44:50 +0200 Subject: [PATCH] Fix proxy error stack trace For current v4.x LTS call to `Error#stack` property getter returns `undefined` if called without binding to `Error` instance. The reason is that internally getter needs error instance to be present as `this`. --- error.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/error.js b/error.js index 73b3012..2f523b8 100644 --- a/error.js +++ b/error.js @@ -42,9 +42,9 @@ module.exports = function createError (name, parameters, Constructor) { // Set up the custom properties for this Error object, if specified. // Create a new stack descriptor that includes the stacks for any errors // also passed in - function createStackDescriptor (errors, previous) { + function createStackDescriptor (errors, previous, proxy) { return function () { - var stack = previous.get(); + var stack = previous.get.call(proxy); errors.forEach(function (error) { stack += '\n'; stack += error.stack; @@ -85,7 +85,7 @@ module.exports = function createError (name, parameters, Constructor) { // descriptor that includes the other error stacks if (errors.length > 0) { properties.stack = { - 'get' : createStackDescriptor(errors, stackDescriptor) + 'get' : createStackDescriptor(errors, stackDescriptor, proxy) }; } // Always set the message manually, in case there was a default supplied