Skip to content

Commit

Permalink
Fix Meteor #7679
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers authored Nov 25, 2019
1 parent d127a9c commit 7284566
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/hijack/wrap_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,37 @@ function wrapMethodHanderForErrors(name, originalHandler, methodMap) {
try{
return originalHandler.apply(this, arguments);
} catch(ex) {
// create a kadira exception
// don't change the original exception so that
// Meteor output of the exception is not impacted
// Meteor #7679
var kex;
if(ex && Kadira._getInfo()) {
// sometimes error may be just an string or a primitive
// in that case, we need to make it a psuedo error
if(typeof ex !== 'object') {
ex = {message: ex, stack: ex};
kex = {message: ex, stack: ex};
} else {
// create a new error via constructor
// set stack properly
if(ex.constructor) {
kex = new ex.constructor();
kex.message = ex.message;
} else {
kex = {message: ex.message};
}
}

// Now we are marking this error to get tracked via methods
// But, this also triggers a Meteor.debug call and
// it only gets the stack
// We also track Meteor.debug errors and want to stop
// tracking this error. That's why we do this
// See Meteor.debug error tracking code for more
if (Kadira.options.enableErrorTracking) {
ex.stack = {stack: ex.stack, source: 'method'};
kex.stack = {stack: kex.stack, source: 'method'};
}
Kadira._getInfo().currentError = ex;
Kadira._getInfo().currentError = kex;
}
throw ex;
}
Expand Down

0 comments on commit 7284566

Please sign in to comment.