Exception: PagarMe::ValidationError

Inherits:
PagarMeError show all
Defined in:
lib/pagarme/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ValidationError

Returns a new instance of ValidationError.



37
38
39
40
41
42
43
44
# File 'lib/pagarme/errors.rb', line 37

def initialize(response)
  @response = response
  @errors   = response['errors'].map do |error|
    params = error.values_at('message', 'parameter_name', 'type', 'url')
    ParamError.new(*params)
  end
  super @errors.map(&:message).join(', ')
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



35
36
37
# File 'lib/pagarme/errors.rb', line 35

def errors
  @errors
end

#responseObject (readonly)

Returns the value of attribute response.



35
36
37
# File 'lib/pagarme/errors.rb', line 35

def response
  @response
end

Instance Method Details

#to_hObject



46
47
48
# File 'lib/pagarme/errors.rb', line 46

def to_h
  @errors.map(&:to_h)
end