Sha256: a2ddb9608e1108191bcbfae272c88d269e05461449abf3f66af0a30b2f6b88bb

Contents?: true

Size: 519 Bytes

Versions: 7

Compression:

Stored size: 519 Bytes

Contents

module QuickTravel
  class AdapterError < StandardError
    attr_reader :response

    def initialize(response)
      @response = if response.is_a? String
                    { 'error' => response }
                  else
                    response.parsed_response
                  end

      error_message = @response.fetch('error', "We're sorry, but something went wrong. Please call us.")
      super(error_message)
    end

    def error_type
      @response.fetch('error_type', 'unspecified')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
quicktravel_client-2.3.1 lib/quick_travel/adapter_error.rb
quicktravel_client-2.3.0 lib/quick_travel/adapter_error.rb
quicktravel_client-2.2.2 lib/quick_travel/adapter_error.rb
quicktravel_client-2.2.1 lib/quick_travel/adapter_error.rb
quicktravel_client-2.2.0 lib/quick_travel/adapter_error.rb
quicktravel_client-2.1.0 lib/quick_travel/adapter_error.rb
quicktravel_client-2.0.0 lib/quick_travel/adapter_error.rb