Method: Caprese::Adapter::JsonApi::Error.attribute_error_objects

Defined in:
lib/caprese/adapter/json_api/error.rb

.attribute_error_objects(record, attribute_name, attribute_errors) ⇒ Object

definition:

JSON Object

properties:

☐ id      : String
☐ status  : String
☐ code    : String
☐ title   : String
☑ detail  : String
☐ links
☐ meta
☑ error_source

description:

id     : A unique identifier for this particular occurrence of the problem.
status : The HTTP status code applicable to this problem, expressed as a string value
code   : An application-specific error code, expressed as a string value.
title  : A short, human-readable summary of the problem. It **SHOULD NOT** change from
  occurrence to occurrence of the problem, except for purposes of localization.
detail : A human-readable explanation specific to this occurrence of the problem.

structure:

{
  title: 'SystemFailure',
  detail: 'something went terribly wrong',
  status: '500'
}.merge!(errorSource)


71
72
73
74
75
76
77
78
79
# File 'lib/caprese/adapter/json_api/error.rb', line 71

def self.attribute_error_objects(record, attribute_name, attribute_errors)
  attribute_errors.map do |attribute_error|
    {
      source: error_source(:pointer, record, attribute_name),
      code: attribute_error[:code],
      detail: attribute_error[:message]
    }
  end
end