From 0e4c49729b8c25004fa9a665a7b4d4f4a2fb611d Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Wed, 20 May 2015 12:44:31 +0200 Subject: [PATCH] window.onerror: log stack to server if available Firefox >= 31 and Chrome >= ~August 2013 pass the Error object as the 5th parameter to window.onerror. https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror https://code.google.com/p/chromium/issues/detail?id=147127 --- static/js/pandora.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/static/js/pandora.js b/static/js/pandora.js index d5f4e7122..d123f47e8 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -21,13 +21,15 @@ appPanel (function() { - window.onerror = function(error, url, line) { + window.onerror = function(error, url, line, column, errorObj) { if (error == 'TypeError: Attempted to assign to readonly property.') { return; } try { + var stack = (errorObj && errorObj.stack) || "(no stack trace available)"; + !isMSIE && !/^resource:/.test(url) && pandora.api.logError({ - text: error, + text: error + "\n\n" + stack, url: document.location.pathname + ' at ' + url, line: line });