Exception: Conexa::ValidationError
- Inherits:
-
ConexaError
- Object
- StandardError
- ConexaError
- Conexa::ValidationError
- Defined in:
- lib/conexa/errors.rb
Overview
Raised for an error body with no message key.
Every error response the published collection documents carries a message,
so in practice this is reached only by an undocumented or malformed body. It
used to render as the bare string "Conexa::ValidationError" and #to_h raised
NoMethodError; both now degrade to something a caller can act on.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response) ⇒ ValidationError
constructor
A new instance of ValidationError.
- #to_h ⇒ Object
Constructor Details
#initialize(response) ⇒ ValidationError
Returns a new instance of ValidationError.
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/conexa/errors.rb', line 105 def initialize(response) @response = response @errors = Array(response.is_a?(Hash) ? response['message'] : nil).filter_map do |msg| next unless msg.is_a?(Hash) ParamError.new(*msg.values_at('message', 'parameter_name', 'type', 'url')) end super(@errors.any? ? @errors.map(&:message).join(', ') : describe(response)) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
103 104 105 |
# File 'lib/conexa/errors.rb', line 103 def errors @errors end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
103 104 105 |
# File 'lib/conexa/errors.rb', line 103 def response @response end |
Instance Method Details
#to_h ⇒ Object
116 117 118 |
# File 'lib/conexa/errors.rb', line 116 def to_h @errors.map(&:to_h) end |