Exception: Antbird::Client::ApiError

Inherits:
Error
  • Object
show all
Defined in:
lib/antbird/client/errors.rb

Direct Known Subclasses

RequestError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ApiError

Returns a new instance of ApiError.



6
7
8
9
10
11
12
13
14
15
# File 'lib/antbird/client/errors.rb', line 6

def initialize(response)
  @response = response
  @status   = response.status

  body = response.body
  @error = body["error"] if body.is_a?(Hash) && body.key?("error")

  message = @error || body.to_s
  super message
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



16
17
18
# File 'lib/antbird/client/errors.rb', line 16

def response
  @response
end

#statusObject (readonly)

Returns the value of attribute status.



16
17
18
# File 'lib/antbird/client/errors.rb', line 16

def status
  @status
end