From a5c22f21467375ac192d790b651b19a029084b71 Mon Sep 17 00:00:00 2001 From: Noam Paz Date: Tue, 23 Jan 2018 11:45:26 +0200 Subject: [PATCH] #1627 Access the .stack property if an error needs to be reported. --- lib/sinon/util/core/wrap-method.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/sinon/util/core/wrap-method.js b/lib/sinon/util/core/wrap-method.js index de0fe0e57..734cb129a 100644 --- a/lib/sinon/util/core/wrap-method.js +++ b/lib/sinon/util/core/wrap-method.js @@ -43,8 +43,8 @@ module.exports = function wrapMethod(object, property, method) { } if (error) { - if (wrappedMethod && wrappedMethod.stackTrace) { - error.stack += "\n--------------\n" + wrappedMethod.stackTrace; + if (wrappedMethod && wrappedMethod.stackTraceError) { + error.stack += "\n--------------\n" + wrappedMethod.stackTraceError.stack; } throw error; } @@ -73,8 +73,8 @@ module.exports = function wrapMethod(object, property, method) { error = new TypeError("Attempted to wrap " + property + " which is already wrapped"); } if (error) { - if (wrappedMethodDesc && wrappedMethodDesc.stackTrace) { - error.stack += "\n--------------\n" + wrappedMethodDesc.stackTrace; + if (wrappedMethodDesc && wrappedMethodDesc.stackTraceError) { + error.stack += "\n--------------\n" + wrappedMethodDesc.stackTraceError.stack; } throw error; } @@ -105,9 +105,9 @@ module.exports = function wrapMethod(object, property, method) { method.displayName = property; - // Set up a stack trace which can be used later to find what line of + // Set up an Error object for a stack trace which can be used later to find what line of // code the original method was created on. - method.stackTrace = (new Error("Stack Trace for original")).stack; + method.stackTraceError = (new Error("Stack Trace for original")); method.restore = function () { // For prototype properties try to reset by delete first.