Exception: BlockBee::APIError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/blockbee.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code) ⇒ APIError

Returns a new instance of APIError.



11
12
13
14
# File 'lib/blockbee.rb', line 11

def initialize(message, status_code)
  super(message)
  @status_code = status_code
end

Instance Attribute Details

#status_codeObject (readonly)

Returns the value of attribute status_code.



9
10
11
# File 'lib/blockbee.rb', line 9

def status_code
  @status_code
end

Class Method Details

.from_status_code(status_code, message) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/blockbee.rb', line 16

def self.from_status_code(status_code, message)
  case status_code
  when 400
    new("Bad Request: #{message}", 400)
  when 401
    new("Unauthorized: #{message}", 401)
  when 403
    new("Forbidden: #{message}", 403)
  when 404
    new("Not Found: #{message}", 404)
  when 500
    new("Internal Server Error", 500)
  else
    new("Unexpected Error: #{message}", status_code)
  end
end