How to customize Ember Data error messages


#1

How can I customize/translate Ember Data generic error messages “Adapter operation failed”. Validation errors I have already translated on server side, but sometimes something unexpected happens (HTTP 500, network error etc). How can I customize those default error messages?


#2

Any ideas how to solve this?


#3

You can override the handResponse() function in your adapter.

http://emberjs.com/api/data/classes/DS.RESTAdapter.html#method_handleResponse

E.g.

handleResponse (status, headers, payload, requestData) {
  if (status === 500) {
    return new Error("My custom error 500 message");
  }

  return payload;
}