emberjs/data — pull request #473 by Osis (2012-11-14 01:42:44+00:00)
Title: Callbacks for 404, 403, 422, and 500 errors for ajax calls

This commit implements callbacks for the usual HTTP error status codes. These callbacks allow you initialize your adapter like so:

```javascript
App.store = DS.Store.create({
revision: 7,
adapter: DS.RESTAdapter.create({
bulkCommit: false,
errorResponse: function(jqXHR) {
console.log('Encoutered ' + jqXHR.status + 'error');
// Set a flag on the current state to prevent multiple renders
if (!App.router.currentState.get('hasError')) {
router = App.router;
// Render Error View
router.get('applicationController').connectOutlet('error')
router.currentState.set('hasError', true);
}
}
})
});
```

There is a case for an error view to replace the entire layout instead of rendering in ApplicationController's outlet. This implementation should be flexible enough to handle this and variety of other scenarios.

I was also thinking that the callback should just return the status code instead of the jqXHR object but again, I like the flexibility of having all the data from the response.