By utilising:
Ember.RSVP.on('error', function(error) {
window.trackJs.track(error);
});
It is possible to send errors to a third party service. Great.
But a common pattern in Ember JS apps is something like this:
this.set('isLoading', true);
ajax('/search')
.then((results) => {
this.set('results', results);
})
.catch((error) => {
this.set('error', 'Something bad happened');
})
.finally(() => {
this.set('isLoading', false);
})
Inadvertently, by catching the error it will not get sent to the third party tracking service.
Ways to solve this:
- Re-throw the error inside the catch
- But this then causes the test suite to have errors in it.
- It also requires developers to remember to re-throw
- It will also cause duplicates errors
- Call the tracking code inside the catch
- This will lead to tracking code being scattered here there and everywhere
- It also requires the developers to remember to track the error
Is there a better way?