Created
May 9, 2013 00:28
-
-
Save joshrhoades/5544713 to your computer and use it in GitHub Desktop.
JS global function to log all uncaught exceptions/errors, with optional method (stub) to fire and log to a server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arrErrors = []; | |
window.onerror = function(msg, fileURL, lineNum) { | |
arrErrors.push({ msg: msg, file: fileURL, line: lineNum }); | |
}; | |
setInterval(function() { | |
sendToServer(arrErrors); | |
arrErrors = []; | |
}, 5000); | |
sendToServer(arrErrors) { | |
//...stub code to log errors to full logging system | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment