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
This commit is contained in:
Will Thompson 2015-05-20 12:44:31 +02:00 committed by j
parent 8b0459592c
commit 0e4c49729b

View file

@ -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
});