This library pulls together several different types of ember errors and reports them in a single event called reportError
. It's meant to be used to send these errors to external reporting services.
ember install:addon ember-cli-uncharted-errors
Once you install this within your project it will automatically pull errors out of Ember.onerror
, Ember.RSVP.error
, Ember.ActionHandler
and error
within the application route. Several events will be spun off depending on the status (if it's an HTTP error.)
If the error received has an HTTP status of 401 it will trigger the event authorizationFailed
. You can capture that in your route and handle appropriately. Here is an example from the UserLoginRoute.
actions: {
authorizationFailed: function(transition) {
var controller = this.controllerFor('user.login');
controller.set('error', true);
controller.set('loading', false);
}
}
If the error received has an HTTP status of 503 it will trigger the event reportUnavailable
. This will essentially mean the server is in maintenance. Handling of this will depend from app to app and this will give you a good spot to notify your users of the maintenance and (optionally) retry the transition.
actions: {
reportUnavailable: function(transition) {
alert('Service is temporarily unavailble');
}
}
The main event in this library is reportError
. It's meant to either report the error to the user or to a third-party system. In this example we're reporting to Sentry.
actions: {
reportError: function(error, context, route, transition) {
if (!window.Raven) {
return;
}
var context;
if (route) {
context = Ember.$.extend(context, {
server_revision: route.get('version.server_version'),
browser_revision: route.get('version.client_version')
});
Raven.setUser({
email: route.get('current_user.email')
id: route.get('current_user.id')
});
}
Raven.captureException(error, { extra: context });
}
}
-
git clone
this repository npm install
bower install
ember server
- Visit your app at http://localhost:4200.
ember test
ember test --server
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.