Exception: BlockScore::InvalidRequestError

Inherits:
APIError
  • Object
show all
Defined in:
lib/blockscore/errors/invalid_request_error.rb

Instance Attribute Summary collapse

Attributes inherited from APIError

#error_type, #http_body, #http_status

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ InvalidRequestError

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



16
17
18
19
# File 'lib/blockscore/errors/invalid_request_error.rb', line 16

def initialize(response)
  super
  @param = @http_body[:error][:param]
end

Instance Attribute Details

#paramObject

Returns the value of attribute param.



3
4
5
# File 'lib/blockscore/errors/invalid_request_error.rb', line 3

def param
  @param
end

Instance Method Details

#to_sObject



21
22
23
24
25
26
27
# File 'lib/blockscore/errors/invalid_request_error.rb', line 21

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