class Almodovar::UnprocessableEntityError
Public Instance Methods
error_messages()
click to toggle source
There are some different kind of errors in Almodovar
servers “errors” => [{“error” => “wadus”}] “errors” => {“error” => [“wadus”, “foo”] “error” => {“message” => “chaflan”}
In case we cannot parse the response an empty array is returned
# File lib/almodovar/errors.rb, line 39 def error_messages @error_messages ||= begin if hash.key?('errors') Array.wrap(hash['errors']).flat_map do |error| error.is_a?(Hash) && error.key?('error') ? error['error'] : error.to_s end elsif hash.key?('error') Array.wrap(hash['error'] && hash['error']['message']) else [] end end end
errors?()
click to toggle source
# File lib/almodovar/errors.rb, line 29 def errors? error_messages.any? end
Private Instance Methods
hash()
click to toggle source
# File lib/almodovar/errors.rb, line 55 def hash @hash ||= begin Hash.from_xml(@response_body) || {} rescue StandardError # The expected errors depends on the ActiveSupport::XmlMini_parser used that it's REXML by default but there # are other, so just rescue a generic error {} end end