Sha256: 5067532f9416ddf566c298b2f60d8421fde202bb6fb70163099bdd24a83d51f5
Contents?: true
Size: 800 Bytes
Versions: 20
Compression:
Stored size: 800 Bytes
Contents
module QuickTravel class AdapterError < StandardError attr_reader :response attr_reader :status def initialize(response) case response when String @response = { 'error' => response } @status = 422 when HTTParty::Response @response = response.parsed_response @status = response.code else fail "Unexpected response type #{response.class}"\ "Should be String or HTTParty::Response" end error_message = if @response.is_a? Hash @response.fetch('error', "We're sorry, but something went wrong. Please call us.") else @response end super(error_message) end def error_type @response.fetch('error_type', 'unspecified') end end end
Version data entries
20 entries across 20 versions & 1 rubygems