Skip to content

Improve error handling in JSONAPI deserializer #139

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

Conversation

jsjohnst
Copy link
Contributor

@jsjohnst jsjohnst commented Sep 9, 2018

  1. Add conditional checks for @payload and data to not return nils
  2. Print a warning when Content-Type header is set to something other than what JSONAPI expects to lead the developer in the right direction to fix the issue.

1) Add conditional checks for `@payload` and `data` to not return nils
2) Print a warning when Content-Type header is set to something other
   than what JSONAPI expects to lead the developer in the right
   direction to fix the issue.
@jsjohnst
Copy link
Contributor Author

jsjohnst commented Sep 9, 2018

I think this handles the situation a bit more cleanly and doesn't need the extra req.method checks that #50 has. For GET/HEAD requests, there isn't a body to deserialize, so those extra checks on the req.method would never be invoked as best as I can tell. Also, as a friend has been bitten multiple times by forgetting to set the content-type header in Postman, I felt a warning there was appropriate. If you would prefer that be a hard error instead of the warning, happy to make that change.

@richmolj
Copy link
Contributor

Thanks @jsjohnst! I think this looks good for now and I'll have to update graphiti with something similar. Beta comes this week!

@richmolj richmolj merged commit c142f24 into jsonapi-suite:master Sep 10, 2018
@richmolj
Copy link
Contributor

Released in 0.11.31

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

Successfully merging this pull request may close these issues.

2 participants