Exception: Interpol::ValidationError

Inherits:
Error
  • Object
show all
Defined in:
lib/interpol/errors.rb

Overview

Error raised when data fails to validate against the schema for an endpoint.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(errors = [], data = nil, endpoint_description = '') ⇒ ValidationError

Returns a new instance of ValidationError.



20
21
22
23
24
25
26
27
28
# File 'lib/interpol/errors.rb', line 20

def initialize(errors = [], data = nil, endpoint_description = '')
  @errors = errors
  error_bullet_points = errors.map { |e| "\n  - #{e}" }.join
  message = "Found #{errors.size} error(s) when validating " +
            "against endpoint #{endpoint_description}. " +
            "Errors: #{error_bullet_points}.\n\nData:\n#{data.inspect}"

  super(message)
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



18
19
20
# File 'lib/interpol/errors.rb', line 18

def errors
  @errors
end