Last active
December 20, 2015 16:39
-
-
Save hungsu/6162665 to your computer and use it in GitHub Desktop.
Alert uncaught errors when they happen
This file contains 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
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