Sending JS errors to server


My app has been released out into the wild and is currently facing an onslaught of the most fearsome of predators, the user. Ember has held up admirably and I’m a full convert.

However, the app has code in there that would best be described as “learning” code and occasionally a user gets a JS error that causes unexpected behavior until the user refreshes the page. Of course, because it is client side, I’m not aware that there’s an issue until I get a call from management.

So question: Is it terrible practice to try and wrap my entire Ember.js app in a last-ditch try...catch block? The goal would be to try and catch the error and then ping my backend from there. Hopefully I could try to pass the stack trace back to my server where I could review it and try to figure out what went wrong. If it’s not a terrible idea, where would I want to put my try..catch block, would it go into app.js somehow?


Doing a try / catch isn’t likely to end well :slight_smile: But that’s actually built into the framework, see under miscellaneous.

I’d also suggest you look at some of the addon said that help with this (for rollbar and airbrake). Even if you want to be rolling your own, you can see how they handle hooking into Ember