Sha256: 44f73b703782cb4c6a195fb8a10e0825f41fc9c83f5af1b6be04da974e85bf17

Contents?: true

Size: 804 Bytes

Versions: 2

Compression:

Stored size: 804 Bytes

Contents

module BlockScore
  class InvalidRequestError < APIError
    attr_accessor :param

    # Public: Creates a new instance of BlockScore::InvalidRequestError.
    #
    # responses - The HTTP response body from HTTParty.
    #
    # Examples
    #
    # begin
    #   response = BlockScore::Person.create(...)
    # rescue BlockScore::InvalidRequestError => e
    #   puts "ERROR: #{e.message} with code #{e.http_status}"
    # end
    def initialize(response)
      super
      @param = @http_body[:error][:param]
    end

    def to_s
      status_string = @http_status ? "(Status: #{@http_status})" : ''
      type_string = @error_type ? "(Type: #{@error_type})" : ''
      param_string = @param ? "(#{@param})" : ''

      "#{type_string} #{@message} #{param_string} #{status_string}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blockscore-4.2.1 lib/blockscore/errors/invalid_request_error.rb
blockscore-4.2.0 lib/blockscore/errors/invalid_request_error.rb