mardi 3 mai 2016

Ember.1.5.1 Uncaught Error: Assertion Failed not caught in ErrorRoutes

I'm getting an Error in Ember 1.5.1 like this:

 Uncaught Error: Assertion Failed: Error: Assertion Failed: You must include an `id` in a hash passed to `push`
Ember.Error @ ember.1.5.1.js:920
Ember.assert @ ember.1.5.1.js:73
Ember.RSVP.onerrorDefault @ ember.1.5.1.js:17187
__exports__.default.trigger @ ember.1.5.1.js:8977
Promise._onerror @ ember.1.5.1.js:9701
publishRejection @ ember.1.5.1.js:10108(anonymous function)
..

The error's reason is that there are some data inconsistencies in the payload.

Even though, I agree, I should take care of this inconsistencies beforehand, when it happens I would like to show an error message and our email contact.

It seems that these types of errors (caused by Ember.assert) are not caught by Ember. What I mean is that, for example, if this error occurs on App.XRoute, I could handle it in the:

App.XRoute = Ember.Route.extend({
     actions: {
        error: function() {
            //do the trick
         }
     }
});

OR in the

App.XErrorRoute = Ember.Route.extend({
    model: function(error) {
        //do the trick
    }
});

OR in App.ErrorRoute

OR using

App.ErrorController =  Ember.ObjectController.extend({

    message: function(){
       return "!!! error: " + this.get('model.stack');
    }.property()
});

ETC..

The problem is that nothing works! Ember simply breaks the execution and that's it. I get an empty screen. Neither of the above error hooks gets called. What else can be done? I'm getting desperate here..

My guess is that it's related to: Ember.assert even though it creates an Ember.Error..

Thanks!




Aucun commentaire:

Enregistrer un commentaire