From 177b8457e0eecf1d547ee1bbb92636af6f342ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Tisza?= Date: Sun, 8 Feb 2015 11:00:17 -0800 Subject: [PATCH] Fix parameters to TraceKit.rethrow * Remove exception rethrowing from TraceKit.report. Raven would catch them again so it is pointless, and it can pollute the stack trace (since TraceKit doesn't extract information from it immediately, only after the rethrow has happened, adding another call to the top of the stack). * Update jsdoc TraceKit.repoer to make clear that additional arguments are passed to the handlers. * Remove the try-catch in Raven.captureException that was made unnecessary by the change. Fixes #300. --- src/raven.js | 13 +------------ vendor/TraceKit/tracekit.js | 10 ++-------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/raven.js b/src/raven.js index e7e33c1c01db..6b2877e4507d 100644 --- a/src/raven.js +++ b/src/raven.js @@ -237,18 +237,7 @@ var Raven = { // Store the raw exception object for potential debugging and introspection lastCapturedException = ex; - // TraceKit.report will re-raise any exception passed to it, - // which means you have to wrap it in try/catch. Instead, we - // can wrap it here and only re-raise if TraceKit.report - // raises an exception different from the one we asked to - // report on. - try { - TraceKit.report(ex, options); - } catch(ex1) { - if(ex !== ex1) { - throw ex1; - } - } + TraceKit.report(ex, options); return Raven; }, diff --git a/vendor/TraceKit/tracekit.js b/vendor/TraceKit/tracekit.js index 07cf4750e081..fdfdc3493608 100644 --- a/vendor/TraceKit/tracekit.js +++ b/vendor/TraceKit/tracekit.js @@ -212,11 +212,9 @@ TraceKit.report = (function reportModuleWrapper() { /** * Reports an unhandled Error to TraceKit. * @param {Error} ex - * @param {?boolean} rethrow If false, do not re-throw the exception. - * Only used for window.onerror to not cause an infinite loop of - * rethrowing. + * @param {...*} extraArgs Any arguments to pass to the registered handlers. */ - function report(ex, rethrow) { + function report(ex, extraArgs) { var args = _slice.call(arguments, 1); if (lastExceptionStack) { if (lastException === ex) { @@ -240,10 +238,6 @@ TraceKit.report = (function reportModuleWrapper() { processLastException(); } }, (stack.incomplete ? 2000 : 0)); - - if (rethrow !== false) { - throw ex; // re-throw to propagate to the top level (and cause window.onerror) - } } report.subscribe = subscribe;