DS.Errors problems



I’m having some problems with server side validation errors using Ember Data. Firstly the versions I’m using are:

  • Ember 1.11.
  • Ember Data 1.0.0-beta.16.1
  • jQuery 1.11.3

As I understand it, if an ajax request fails my adapter (RESTAdapter) receives the failed request:

ajaxError: function(jqXHR) {
  var error = this._super(jqXHR);

   if (jqXHR && jqXHR.status === 500) {
     var jsonErrors = Ember.$.parseJSON(error.responseText);
     return new DS.InvalidError(jsonErrors);
   } else {
     return error;

This should then populate the models errors property with the server sent errors, I’m getting this json from a failed request:

   name: ['Name is not valid']

But when ever a failed request comes back I get the following error:

TypeError: recordErrors.add is not a function
at Ember.Object.extend.adapterDidInvalidate (model.js:1131)
at ember$data$lib$system$store$$Service.extend.recordWasInvalid (store.js:1310)
at store.js:2040
at tryCatch (ember.debug.js:46937)
at invokeCallback (ember.debug.js:46949)
at publish (ember.debug.js:46920)
at publishRejection (ember.debug.js:46862)
at ember.debug.js:27239
at Queue.invoke (ember.debug.js:871)
at Object.Queue.flush (ember.debug.js:936)

I’ve done some digging and it would seem that the recordErrors is not actually an instance of DS.Errors.

Any help would be really appreciated.