How do you set up Airbrake such that it gets context information from unhandled Javascript errors that occur in an Ember application?
Assuming you've included Airbrake-js you can hook on Ember's onerror handler and push 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 options of different parameters of the data sent in the airbrake-js GitHub repository docs.
I don't know if this answers your question, but I hope it helps.
To handle server thrown errors you can define an "error" function in the application's route and push it in Airbrake:
App.ApplicationRoute = Ember.Route.extend({
  actions: {
    error: function(error) {
      // handle the error
      Airbreak.push(error)
    }
  }
});
Moreover, if you catch errors somewhere else and have the same handling, you can make a 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);
    }
});
This way you have all the error handling in a single place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With