1
votes

It looks like the latest versions of ember-data removed the rejectionHandler. Here is the old code https://github.com/emberjs/data/blob/4764b5d70c41c133edcbd1822bc587483c39e180/packages/ember-data/lib/adapters/rest_adapter.js#L11-L15 and example usage https://github.com/emberjs/data/blob/4764b5d70c41c133edcbd1822bc587483c39e180/packages/ember-data/lib/adapters/rest_adapter.js#L372.

I was using this to handle 401 unauthorized status codes from my server. Can I accomplish the same thing using the latest ember-data? I know I could pass a second function to all find and save calls to handle failure. But how to do that application wide?

1

1 Answers

2
votes

To do that application-wide you should use the global error handling capabilities of the router.

App.ApplicationRoute = Ember.Route.extend({
  actions: {
    error: function(error, transition) {
      //If error was a 401, do something...
    }
  }
});

See How to do cool stuff with the new Router API