Skip to content

Instantly share code, notes, and snippets.

@hungsu
Last active December 20, 2015 16:39
Show Gist options
  • Save hungsu/6162665 to your computer and use it in GitHub Desktop.
Save hungsu/6162665 to your computer and use it in GitHub Desktop.
Alert uncaught errors when they happen
window.onerror = function(msg, url, line) {
// You can view the information in an alert to see things working
// like so:
alert("Error: " + msg + "\nurl: " + url + "\nline #: " + line);
// TODO: Report this error via ajax so you can keep track
// of what pages have JS issues
var suppressErrorAlert = true;
// If you return true, then error alerts (like in older versions of
// Internet Explorer) will be suppressed.
return suppressErrorAlert;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment