jeudi 15 octobre 2015

Handle first route errors in Ember.js

I would like to handle errors that happen in the first route within ember and if the error action is called redirect to another route.

How would i determine if this is a first route upon error being invoked and if it is a first route, re-route to route say index. BUT if it is not first route just return true and let the error bubble up.

Getting this error whenever i retry the transition object

Uncaught Error: Can't trigger action 'error' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call .send() on the Transition object passed to the model/beforeModel/afterModel hooks.

Here is my setup :

ember.js:15373 DEBUG: Ember       : 1.8.1
ember.js:15373 DEBUG: Handlebars  : 1.3.0
ember.js:15373 DEBUG: jQuery      : 1.11.3
ember.js:15373 DEBUG: Ember Model : 0.0.14

This would be my parent route that all other routes inherit from

export default Ember.Route.extend({
 actions: {
  error: function(error, transition) {
   //FAKE CODE NOT SURE HOW TO TELL I AM IN THE FIRST ROUTE
   if(this.firstRoute){
     this.transitionTo('index');
   } else{
     return true;
    }
   }
 }
});

Aucun commentaire:

Enregistrer un commentaire