Last active
June 9, 2017 17:37
-
-
Save illright/4f9ef2d181a8bcd82657cdc331eed370 to your computer and use it in GitHub Desktop.
JS snippet to redirect errors to an alert (for debugging in Safari)
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.addEventListener('error', handleError, true); | |
function handleError(event) { | |
if (event.message) { | |
window.alert('error: ' + event.message + ' at linenumber: ' + event.lineno + ' of file: ' + event.filename); | |
} else { | |
window.alert('error: ' + event.type + ' from element: ' + (event.srcElement || event.target)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment