Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActiveModel adapter 422 error handling #1977

Closed
fsmanuel opened this issue May 27, 2014 · 3 comments
Closed

ActiveModel adapter 422 error handling #1977

fsmanuel opened this issue May 27, 2014 · 3 comments

Comments

@fsmanuel
Copy link
Contributor

@igorT Is it possible to consider the attrs hash here?

Right now the errors from the server doesn't match custom mappings and are worthless.

@igorT
Copy link
Member

igorT commented May 28, 2014

Yes, this seems like a bug. I'll try and make a PR, but it might need to be a part of a slightly bigger refactor.

@ahacking
Copy link
Contributor

I have been looking at how errors are handled in Ember Data as I want to ensure the following:

  • payload error keys get mapped to model keys consistently with how the serializer maps payload keys in the success case
  • embedded models (ie using the embeded_records_mixin) also get their errors property setup

This is really a common problem for all serializers, not just ActiveModel as the store currently by-passes the serializer when there is an InvalidError and pushes errors directly into the model here.

A possible solution would be to introduce extractInvalid on the serializer class and call extract from the store here passing 'Invalid' as the operation type analogous to what is done in the success case a few lines above.

@igorT Has there been any progress on this?

The reason I ask is I need to solve this for a project pretty urgently so if there is some existing work I can base my changes on I will look at that, or if you can recommend a better way forward I will consider that too.

I will also look at what other enhancements are needed so that embedded record handling can extract errors pertaining to those record instances.

@igorT
Copy link
Member

igorT commented Oct 16, 2014

@ahacking I haven't worked on this personally, your PR looks great.

@igorT igorT closed this as completed Oct 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants