Exception: LoopsSdk::APIError
- Inherits:
-
StandardError
- Object
- StandardError
- LoopsSdk::APIError
- Defined in:
- lib/loops_sdk/base.rb
Instance Attribute Summary collapse
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#statusCode ⇒ Object
readonly
Returns the value of attribute statusCode.
Instance Method Summary collapse
-
#initialize(status, body) ⇒ APIError
constructor
A new instance of APIError.
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 = begin parsed = JSON.parse(body) parsed["message"] ? ": #{parsed["message"]}" : "" rescue JSON::ParserError "" end super("API request failed with status #{statusCode}#{}") end |
Instance Attribute Details
#json ⇒ Object (readonly)
Returns the value of attribute json.
49 50 51 |
# File 'lib/loops_sdk/base.rb', line 49 def json @json end |
#statusCode ⇒ Object (readonly)
Returns the value of attribute statusCode.
49 50 51 |
# File 'lib/loops_sdk/base.rb', line 49 def statusCode @statusCode end |