jsonapi-suite / jsonapi_compliable

MIT License
20 stars 35 forks source link

Improve error handling in JSONAPI deserializer #139

Closed jsjohnst closed 6 years ago

jsjohnst commented 6 years ago
  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 commented 6 years ago

I think this handles the situation a bit more cleanly and doesn't need the extra req.method checks that https://github.com/jsonapi-suite/jsonapi_compliable/pull/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 commented 6 years ago

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

richmolj commented 6 years ago

Released in 0.11.31