In my EmberJS application, I am using the various "error" template to render specific error messages whenever I cannot access a ressource. For instance, I have a template called "reset-password/error.hbs" that is rendered when I try to access an invalid reset password.
This works really well.
However today, I added an "error" action in my ApplicationRoute. The goal was to catch a very specific error that could potentially happening in all pages (the 401 error), and I want to use this to invalidate my session. Therefore, in my application route, I have the following code:
export default Ember.Route.extend({
actions: {
error: function(result) {
if (result.status === 401) {
this.get('session').invalidate();
}
}
}
});
The problem is that with this code, my error template for "reset-password" is no longer shown. Naively, I thought that Ember, given an error occurs on "reset-password/index" route, would:
- First check on a "error" action on "ResetPasswordIndexRoute".
- Then try to render "reset-password/error.hbs" if it exists.
- Then bubbles up... until it reaches "application", and finally find the "error" action in ApplicationRoute.
But it seems that as soon an "error" action is defined, even if it's much higher in the hierarchy, it completely replaces any template that could be here...
How could I work around this, and still have the two error handler? I've tried to called "_super" in the error action, but no result.
Thanks!
Aucun commentaire:
Enregistrer un commentaire