Exception: Linketysplit::ApiError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ApiError

Returns a new instance of ApiError.



11
12
13
14
15
16
# File 'lib/linketysplit/api_endpoints.rb', line 11

def initialize(response)
  @status_code = response.code
  data = JSON.parse(response.body)
  message = data["message"].is_a?(String) ? data["message"] : "An unknown error occurred"
  super(message)
end

Instance Attribute Details

#status_codeObject (readonly)

Returns the value of attribute status_code.



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

def status_code
  @status_code
end