Exception: FitbitClient::Error
- Inherits:
-
StandardError
- Object
- StandardError
- FitbitClient::Error
- Defined in:
- lib/fitbit_client/error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(message, response = nil) ⇒ Error
constructor
A new instance of Error.
- #json_response ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(message, response = nil) ⇒ Error
Returns a new instance of Error.
7 8 9 10 |
# File 'lib/fitbit_client/error.rb', line 7 def initialize(, response = nil) @message = @response = response end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/fitbit_client/error.rb', line 5 def response @response end |
Instance Method Details
#json_response ⇒ Object
12 13 14 |
# File 'lib/fitbit_client/error.rb', line 12 def json_response @json_response ||= JSON.parse(response.body) if response end |
#to_s ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/fitbit_client/error.rb', line 16 def to_s if response "#{@message}, HTTP_STATUS: #{response.status}, HTTP_BODY: #{response.body}, HTTP_URL: #{response.response.env.url}" else @message.to_s end end |