Exception: LoopsSdk::APIError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, body) ⇒ APIError

Returns a new instance of APIError.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/loops_sdk/base.rb', line 51

def initialize(status, body)
  @statusCode = status
  @json = body
  message = begin
              parsed = JSON.parse(body)
              parsed["message"] ? ": #{parsed["message"]}" : ""
            rescue JSON::ParserError
              ""
            end
  super("API request failed with status #{statusCode}#{message}")
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



49
50
51
# File 'lib/loops_sdk/base.rb', line 49

def json
  @json
end

#statusCodeObject (readonly)

Returns the value of attribute statusCode.



49
50
51
# File 'lib/loops_sdk/base.rb', line 49

def statusCode
  @statusCode
end