Exception: Cashboard::BadRequest

Inherits:
HTTPError
  • Object
show all
Defined in:
lib/cashboard/errors.rb

Instance Attribute Summary

Attributes inherited from HTTPError

#response

Instance Method Summary collapse

Methods inherited from HTTPError

#initialize

Constructor Details

This class inherits a constructor from Cashboard::HTTPError

Instance Method Details

#errorsObject

Returns a hash of errors keyed on field name.

Return Example

{
  :field_name_one => "Error message",
  :field_name_two => "Error message"
}


39
40
41
42
43
44
45
46
# File 'lib/cashboard/errors.rb', line 39

def errors
  parsed_errors = XmlSimple.xml_in(response.response.body)
  error_hash = {}
  parsed_errors['error'].each do |e|
    error_hash[e['field']] = e['content']
  end
  return error_hash
end

#to_sObject

Custom parses our “errors” return XML



28
29
30
# File 'lib/cashboard/errors.rb', line 28

def to_s
  response.response.body 
end