Exception: Incognia::APIError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, response_info = {}) ⇒ APIError

Returns a new instance of APIError.



30
31
32
33
34
# File 'lib/incognia_api.rb', line 30

def initialize(message, response_info = {})
  @status = response_info[:status]
  @errors = response_info[:body]
  @message = format_message(message)
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



28
29
30
# File 'lib/incognia_api.rb', line 28

def errors
  @errors
end

#messageObject (readonly)

Returns the value of attribute message.



28
29
30
# File 'lib/incognia_api.rb', line 28

def message
  @message
end

#statusObject (readonly)

Returns the value of attribute status.



28
29
30
# File 'lib/incognia_api.rb', line 28

def status
  @status
end

Instance Method Details

#format_message(initial_message) ⇒ Object



40
41
42
43
# File 'lib/incognia_api.rb', line 40

def format_message(initial_message)
  message = "[HTTP #{status}]: #{initial_message}"
  message += "\n#{errors}" if errors
end

#to_sObject



36
37
38
# File 'lib/incognia_api.rb', line 36

def to_s
  message
end