Setting up Airbrake on the Ember app

How do you set Airbrake to get contextual information from the raw Javascript errors that occur in the Ember app?

+6
source share
2 answers

Assuming you have enabled Airbrake-js , you can hook up the Ember onerror handler and click on the errors.

 Ember.onerror = function(err) { // any ember error Airbrake.push(err); //any other error handling }; Ember.RSVP.configure('onerror',function(err){ // any promise error Airbrake.push(err); console.error(e.message); console.error(e.stack); //any other generic promise error handling }; window.onerror = function(err){ // window general errors. Airbrake.push(err); //generic error handling that might not be Airbrake related. }; 

You can see more parameters of different data parameters sent in the airbrake-js GitHub data warehouse documents.

+8
source

I don’t know if this answers your question, but I hope this helps.

To handle errors caused by the server, you can define the "error" function in the application route and click it in "Airbrake":

 App.ApplicationRoute = Ember.Route.extend({ actions: { error: function(error) { // handle the error Airbreak.push(error) } } }); 

In addition, if you catch errors somewhere else and have the same processing, you can do mixin and pass the error:

 App.ErrorHandlerMixin = Ember.Mixin.create({ handleError: function(error){ //make different stuff Airbreak.push(error) } }); App.ApplicationRoute = Ember.Route.extend(App.ErrorHandlerMixin, { actions: { error: function(error, transition) { this.handleError(error); } } }); App.ApplicationController = Ember.ObjectController.extend((App.ErrorHandlerMixin, { someFunction: function () { this.handleError(randomError); } }); 

That way you have all the error handling in one place.

+1
source

All Articles