Handling errors in ember-data


#1

How can do you handle errors from backend in ember-data 14 RESTAdapter? And is there a specific formatting for the JSON response?


#2

the formating to json I think is like rails output. something like http://emberjs.com/guides/getting-started/using-fixtures/


#3

I was asking about the errors. Is there a specific formatting like should the root be error, errors, or model…etc


#4

Did you ever work out what the best way to return errors from a backend was? I’m starting a new project and would love to know!


#5

I’m using reason.responseJSON.errors, where i can pass anything from message: "hooray", to objects "email": ["invalid format"].

    content.send().fail (reason) ->
        reason.responseJSON.errors


#6

@joeserg Ember data works using this format with ActiveModelSerializer. Not sure about the default.

{ 
  errors: {
    email: ['is already taken'],
    password: ['is missing']
  }
}

in your template you can just access it by errors.email and in .fail (reason) promise you can access it via reason.errors.email

Hope this helps