Exception: ViralLoops::ApiError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, body: nil, message: nil) ⇒ ApiError

Returns a new instance of ApiError.



52
53
54
55
56
57
58
59
# File 'lib/viral_loops/client.rb', line 52

def initialize(status:, body: nil, message: nil)
  @status = status
  @status_symbol = Rack::Utils::SYMBOL_TO_STATUS_CODE.key(status)
  @body = body

  default_message = Rack::Utils::HTTP_STATUS_CODES[status] || 'API Error'
  super(message || "#{default_message} (#{status})")
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



50
51
52
# File 'lib/viral_loops/client.rb', line 50

def body
  @body
end

#statusObject (readonly)

Returns the value of attribute status.



50
51
52
# File 'lib/viral_loops/client.rb', line 50

def status
  @status
end

#status_symbolObject (readonly)

Returns the value of attribute status_symbol.



50
51
52
# File 'lib/viral_loops/client.rb', line 50

def status_symbol
  @status_symbol
end