From fc9c595dbbd51bd5d9880c150ff0bb0f1a1af54b Mon Sep 17 00:00:00 2001 From: Devin Rhode Date: Tue, 16 Jul 2013 14:10:12 -0700 Subject: [PATCH 1/3] Allow an old onerror function to tell TraceKit to not notify handlers Hopefully no build errors this time :) --- tracekit.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tracekit.js b/tracekit.js index 78bb33b..554b0f4 100644 --- a/tracekit.js +++ b/tracekit.js @@ -180,10 +180,17 @@ TraceKit.report = (function reportModuleWrapper() { }; } - notifyHandlers(stack, 'from window.onerror'); - if (_oldOnerrorHandler) { - return _oldOnerrorHandler.apply(this, arguments); + var _oldOnerrorReturn = _oldOnerrorHandler.apply(this, arguments); + + // if there is no return value or that return value has notifyHandlers set to something truthy, notifyHandlers + if (!_oldOnerrorReturn || _oldOnerrorReturn.notifyHandlers) { + notifyHandlers(stack, 'from window.onerror'); + } + + return _oldOnerrorReturn; // preserve any potential return behavior of the old onerror function. + } else { + notifyHandlers(stack, 'from window.onerror'); } return false; From bad90312d0de524ed997641bbcb2bfdf317388ac Mon Sep 17 00:00:00 2001 From: Devin Rhode Date: Tue, 16 Jul 2013 14:14:44 -0700 Subject: [PATCH 2/3] Docs for letting an old onerror function tell TraceKit to not notify handlers --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7d5aac0..5d97c22 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,11 @@ You can also tell TraceKit to ignore global window errors with: TraceKit.collectWindowErrors = false; ``` +### Existing `window.onerror` function? + +TraceKit installs it's own window.onerror function, but your will still get called normally. +If you don't want TraceKit to notify subscribers, then `return {notifyHandlers: false};` from your window.onerror function. + View the source for more details and examples. ![Stacktrace or GTFO](http://i.imgur.com/jacoj.jpg) From dd6d425608495ae1db5710384476954d410c6b4e Mon Sep 17 00:00:00 2001 From: Devin Rhode Date: Tue, 16 Jul 2013 14:17:38 -0700 Subject: [PATCH 3/3] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d97c22..719e5ac 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ TraceKit.collectWindowErrors = false; ### Existing `window.onerror` function? -TraceKit installs it's own window.onerror function, but your will still get called normally. +TraceKit installs it's own window.onerror function, but yours will still get called normally. If you don't want TraceKit to notify subscribers, then `return {notifyHandlers: false};` from your window.onerror function. View the source for more details and examples.