Sha256: ddb3a541bb7921a623cbea11ba6c4db3c4f8a03f0d25f3fd4b5df2c0482e6a75
Contents?: true
Size: 802 Bytes
Versions: 5
Compression:
Stored size: 802 Bytes
Contents
module Conekta class ErrorList < Exception attr_accessor :details def initialize @details = [] end def self.error_handler(response, http_status) exception = nil if response.instance_of?(Hash) if response.has_key?("details") error_list = ErrorList.new response["details"].each do |error| error_list.details << self.build_error(error, http_status) end error_list.details << self.build_error(nil, nil) if error_list.details.empty? exception = error_list end end exception ||= self.build_error(response, http_status) raise exception end private def self.build_error(response, http_status) Error.error_handler(response, http_status) end end end
Version data entries
5 entries across 5 versions & 1 rubygems