Closed arefaslani closed 6 years ago
Hi @arefaslani. It really depends how you're serializing your errors. If you're using custom error serializers, you can use the code
DSL method.
@beauby How should I use the code
DSL? I tested it as:
render jsonapi_errors: outcome.errors, code: 100, status: :unprocessable_entity
but it doesn't work. I use ActiveInteraction as the I in DCI. This is my configuration for jsonapi:
JSONAPI::Rails.configure do |config|
# Set a default serializable class mapping for errors.
config.jsonapi_errors_class = Hash.new { |h, k|
}.tap { |h|
h[:'ActiveModel::Errors'] = JSONAPI::Rails::SerializableActiveModelErrors
h[:'ActiveInteraction::Errors'] = JSONAPI::Rails::SerializableActiveModelErrors
h[:Hash] = JSONAPI::Rails::SerializableErrorHash
}
end
Here is how JSON API describes error code.
@beauby I can't find code DSL and how to use it anywhere...
I want to render error
code
property, as JSON API specification describes, withjsonapi_errors
method. How could I set the code property in error object?