Skip to content

Instantly share code, notes, and snippets.

@sehrgut
Created November 24, 2015 17:22
Show Gist options
  • Save sehrgut/caffcf820597f76f6ad4 to your computer and use it in GitHub Desktop.
Save sehrgut/caffcf820597f76f6ad4 to your computer and use it in GitHub Desktop.
logs uncaught exceptions which bubble up to window.onerror
window.onerror = (function () {
var old_err = window.onerror;
var new_err = function (msg, url, line, col, err) {
console.log("Line " + line + ":" + col + " - " + msg);
if (typeof err.stack !== 'undefined')
console.log(err.stack);
else
console.log(err);
if (old_err) old_err(msg, url, line, col, err);
};
new_err.detach = function () { window.onerror = old_err; }
return new_err;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment