diff options
Diffstat (limited to 'node_modules/error-ex/index.js')
-rw-r--r-- | node_modules/error-ex/index.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/node_modules/error-ex/index.js b/node_modules/error-ex/index.js index 43641b08f..4fb20b487 100644 --- a/node_modules/error-ex/index.js +++ b/node_modules/error-ex/index.js @@ -51,20 +51,28 @@ var errorEx = function errorEx(name, properties) { } }); + var overwrittenStack = null; + var stackDescriptor = Object.getOwnPropertyDescriptor(this, 'stack'); var stackGetter = stackDescriptor.get; var stackValue = stackDescriptor.value; delete stackDescriptor.value; delete stackDescriptor.writable; + stackDescriptor.set = function (newstack) { + overwrittenStack = newstack; + }; + stackDescriptor.get = function () { - var stack = (stackGetter) - ? stackGetter.call(this).split(/\r?\n+/g) - : stackValue.split(/\r?\n+/g); + var stack = (overwrittenStack || ((stackGetter) + ? stackGetter.call(this) + : stackValue)).split(/\r?\n+/g); // starting in Node 7, the stack builder caches the message. // just replace it. - stack[0] = this.name + ': ' + this.message; + if (!overwrittenStack) { + stack[0] = this.name + ': ' + this.message; + } var lineCount = 1; for (var key in properties) { |