Currently in the process of upgrading quite a large EmberJS app all the way from 1.7 to 1.13 (and then 2.0 later). We're pretty much there now.
We handle errors from the server differently depending on the HTTP status code. Our current code goes a little like this...
model.save().then(
// Success
function() { /* ... */ },
// Failure
function(response) {
switch (response.status) {
case 403:
/* ... */
case 422:
/* ... */
case 500:
/* ... */
default:
/* ... */
}
}
)
Previously, we could just get the status code from the status
attribute. Now, that doesn't exist because the response
variable is an instance of DS.InvalidError or DS.AdapterError.
Question
How can we get the status code?
Alternatively, how can we distinguish between the different possible response classes (DS.InvalidError
and DS.AdapterError
)?
Versions
- Ember: 1.13.6
- Ember Data: 1.13.7