Exception: BlockScore::BlockscoreError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/blockscore/error/blockscore_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, json_body = nil, http_status = "400", error_type = "invalid_request_error") ⇒ BlockscoreError

Returns a new instance of BlockscoreError.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/blockscore/error/blockscore_error.rb', line 9

def initialize(message=nil, json_body=nil, http_status="400",
                error_type="invalid_request_error")
  super(message)

  message_desc = "#{json_body["error"]["param"]} #{json_body["error"]["code"]}"

  @error_type = error_type 
  @http_status = http_status
  @json_body = json_body
  @message = "#{message} (#{message_desc})"
end

Instance Attribute Details

#error_typeObject (readonly)

Returns the value of attribute error_type.



5
6
7
# File 'lib/blockscore/error/blockscore_error.rb', line 5

def error_type
  @error_type
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



6
7
8
# File 'lib/blockscore/error/blockscore_error.rb', line 6

def http_status
  @http_status
end

#json_bodyObject (readonly)

Returns the value of attribute json_body.



7
8
9
# File 'lib/blockscore/error/blockscore_error.rb', line 7

def json_body
  @json_body
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/blockscore/error/blockscore_error.rb', line 4

def message
  @message
end

Instance Method Details

#to_sObject



21
22
23
# File 'lib/blockscore/error/blockscore_error.rb', line 21

def to_s
  "Status: #{@http_status}. Type: #{@error_type}, Message: #{@message}"
end