Class: RaindropIo::ApiError
- Inherits:
-
Object
- Object
- RaindropIo::ApiError
- Defined in:
- lib/raindrop_io/api.rb
Overview
A wrapper around api errors
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#response ⇒ Object
readonly
to view the raw response for debugging.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(response) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(response) ⇒ ApiError
Returns a new instance of ApiError.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/raindrop_io/api.rb', line 10 def initialize(response) @status = response.code if response.content_type.mime_type.nil? @message = response.to_s elsif response.content_type.mime_type == "application/json" @message = if response.status.success? response.parse else response.parse["errorMessage"] end end @response = response end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/raindrop_io/api.rb', line 7 def @message end |
#response ⇒ Object (readonly)
to view the raw response for debugging
8 9 10 |
# File 'lib/raindrop_io/api.rb', line 8 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/raindrop_io/api.rb', line 7 def status @status end |