Skip to content

Instantly share code, notes, and snippets.

@joshrhoades
Created May 9, 2013 00:28
Show Gist options
  • Save joshrhoades/5544713 to your computer and use it in GitHub Desktop.
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.
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