Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Access the .stack property if an error needs to be reported.
  • Loading branch information
NoamPaz authored and Franck Romano committed Oct 1, 2019
1 parent 4224b62 commit a242416
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/sinon/util/core/wrap-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit a242416

Please sign in to comment.