Any thoughts on handling 401 errors?
In the application initializer I'm deferring readiness and fetching the current user via ember-data. If I receive a 401 the app dies and becomes unusable. I'd like to handle this error, and then advancereadiness. I cant seem to find a workaround for this. Any info would be appreciated!
Gist here: https://gist.github.com/unknpwn/6126462
I noticed there was a similar topic here, but it seems to be out of date.
The previous answer is outdated. In current Ember version (1+) events
are deprecated and you should use actions
object (instead of function).
Ember example:
App.ApplicationRoute = Ember.Route.extend({
actions: {
error: function(err) {
// error handler called in case of an error.
// show the error message to user here
// or transition to another route
}
}
});
Ember CLI example:
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
error: function(err) {
// error handler called in case of an error.
// show the error message to user here
// or transition to another route
}
}
});
With these action handlers the error will bubble nicely to the main application route if you don't stop it before in your route.
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