Skip to content

Instantly share code, notes, and snippets.

Created December 16, 2012 02:51
Show Gist options
  • Save anonymous/4302682 to your computer and use it in GitHub Desktop.
Save anonymous/4302682 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. [inspiration](http://bytes.com/topic/javascript/answers/90742-try-catch-error-handling-display-line-number)
onerror = (err, file, line) ->
logger """ # console.log, alert, whatever
The following error occured: #{err}
In file: #{file}
At line: #{line}
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment