-
-
Save ethagnawl/4302686 to your computer and use it in GitHub Desktop.
An onerror handler that's a helluva lot more useful than `... catch(e) { alert(e) }`.You can easily hook this into a custom Google Analytics event to log your app's errors. Inspired by: http://bytes.com/topic/javascript/answers/90742-try-catch-error-handling-display-line-number
This file contains hidden or 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
onerror = (err, file, line) -> | |
logger """ # console.log, alert, whatever | |
The following error occured: #{err} | |
In file: #{file} | |
At line: #{line} | |
""" |
This file contains hidden or 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
var onerror = function(err, file, line) { | |
return alert("The following error occured: " + err + "\nIn file: " + file + "\nAt line: " + line); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Whoops - I didn't mean to publish this anonymously.
Forking for posterity. :)