Exception: Mautic::ValidationError
- Inherits:
-
RequestError
- Object
- StandardError
- RequestError
- Mautic::ValidationError
- Defined in:
- lib/mautic.rb
Instance Attribute Summary
Attributes inherited from RequestError
#errors, #request_url, #response
Instance Method Summary collapse
-
#initialize(response, message = nil) ⇒ ValidationError
constructor
A new instance of ValidationError.
Constructor Details
#initialize(response, message = nil) ⇒ ValidationError
Returns a new instance of ValidationError.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mautic.rb', line 49 def initialize(response, = nil) @response = response json_body = begin JSON.parse(response.body) rescue ParseError {} end @errors = Array(json_body['errors']).inject({}) { |mem, var| mem.merge!(var['details']); mem } ||= @errors.collect { |field, msg| "#{field}: #{msg.join(', ')}" }.join('; ') super(response, ) end |