active_model_serializers: Serializing errors
The JSON API docs currently state (I’m not sure if they said this before JSON API 1.0):
A document MUST contain at least one of the following top-level members:
data: containing the document's "primary data"
errors: containing an array of error objects
meta: non-standard meta-information.
The members data and errors MUST NOT coexist in the same document.
Is there a way to render the errors member in master / v0.10.0.rc1?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 23 (18 by maintainers)
This is what I use in my app:
Wanted to copy the PR description from #1004 to track further changes / remaining TODOs
Courtesy of @bf4
Usage
Requires explicit passing of Error serializer
PR TODOS:
jsonapi/errors.md
Error object:
Serializing errors is different from resources.
ActiveModel::Error
, which we’d want to callmodel.errors.messages
on.ActiveModel::Error
is necessarily a collection of error objects, each with it’s own'source'
and'detail'
Full Error API Implementation:
Implementation tests:
test/action_controller/json_api/errors_test.rb
test/action_controller/rescue_from_test.rb
rescue_with_handler
,handle_exceptions
Other implementations
ref: