Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended error reporting for ember.js

Tags:

ember.js

What is the ember.js community recommendation for reporting Ember app crashes? I'm looking for the equivalent of the exception_notifier gem in Rails so that I can be notified if users are experiencing errors.

This Stack Overflow post recommends generic javascript error handling solutions including:

  • Handle window.onerror yourself
  • Use a hosted service that handles window.onerror for you like Airbrake.io or Muscula

I'm hoping there is some kind of Mixin that gives you all this error handling code, and provides richer error messages (such as the current route when the error occurred, etc). Does this exist yet? If not, what are people doing to solve this problem?

like image 929
jefflab Avatar asked Jan 16 '13 00:01

jefflab


People also ask

Is Ember js still popular?

6.3% of javascript developers are currently using Ember. Its popularity has stagnated over the last few years. Ranked 4rd most popular front-end JavaScript framework in State Of JS survey.

How good is Ember js?

Ember. js offers you a well-organized and trustworthy framework. When the development team is big, this is the framework that suits best. It allows everyone to understand the written code and contribute to a common project.

Is Ember js a framework or library?

Ember. js is a JavaScript framework for creating ambitious web applications.

What can you do with Ember js?

Ember. js is an open source, free JavaScript client-side framework used for developing web applications. It allows building client side JavaScript applications by providing a complete solution which contains data management and an application flow. The original name of Ember.


1 Answers

Any error reporting like the Rails gem is going to depend on some sort of server backend to handle the error, such as emailing admins, etc. It makes sense that Rails would have a whole gem dedicated to this sort of thing, since Rails is going to have the whole stack trace, session, and all sorts of other variables that are convenient(/necessary) to have for debugging the issue, but for front-end apps (e.g. Ember), all the error information is on the client side, so all the backend logic would do is expose an API that your Ember app can talk to which would forward whatever information you send to it from the app and send it to your email, or whatever you want to do with it.

To do this in Ember, you can specify the Ember.onerror function:

Ember.onerror = function(error) {
  caught = error; 
  Em.$.ajax('/report-error', 'POST', {
     stack: error.stack,
     otherInformation: 'whatever app state you want to provide'
  });
};

This receives the JavaScript Error object that was thrown, which may or may not have the non-standard stack property that contains the stack trace which you could send to the server among any other App-specific state you'd want to send, though you'd probably want to keep it simple so that you don't cause other errors and end up in a crazy error loop from hell.

like image 133
Alexander Wallace Matchneer Avatar answered Sep 19 '22 21:09

Alexander Wallace Matchneer