Exception: JsonapiErrorsHandler::Errors::Invalid
- Inherits:
-
StandardError
- Object
- StandardError
- StandardError
- JsonapiErrorsHandler::Errors::Invalid
- Defined in:
- lib/jsonapi_errors_handler/errors/invalid.rb
Overview
Handles serialization of invalid HTTP error (422 status code)
Instance Attribute Summary
Attributes inherited from StandardError
#detail, #source, #status, #title
Instance Method Summary collapse
-
#initialize(errors: {}) ⇒ Invalid
constructor
A new instance of Invalid.
- #serializable_hash ⇒ Object
Methods inherited from StandardError
Constructor Details
#initialize(errors: {}) ⇒ Invalid
Returns a new instance of Invalid.
8 9 10 11 12 |
# File 'lib/jsonapi_errors_handler/errors/invalid.rb', line 8 def initialize(errors: {}) @errors = errors @status = 422 @title = 'Invalid request' end |
Instance Method Details
#serializable_hash ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jsonapi_errors_handler/errors/invalid.rb', line 14 def serializable_hash errors.reduce([]) do |r, (att, msg)| r << { status: status.to_s, title: title, detail: msg, source: { pointer: "/data/attributes/#{att}" } } end end |