0.0.9 • Published 9 years ago

ember-cli-uncharted-errors v0.0.9

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

UnchartedCode Errors Build Status

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.

Installation

ember install:addon ember-cli-uncharted-errors

Usage

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.)

Unauthorized

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);
    }
  }

Unavailable

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');
    }
  }

Error

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 });
    }
  }

Development

Installation

  • git clone this repository
  • npm install
  • bower install

Running

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago