Class: ActiveResource::ClientError
- Inherits:
-
ConnectionError
- Object
- ConnectionError
- ActiveResource::ClientError
- Defined in:
- lib/liquidplanner/ext/exceptions.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(response, message = nil) ⇒ ClientError
constructor
Extend client errors so that they annotate the response message with the details from a JSON response.
-
#to_s ⇒ Object
Return the default exception message with the extracted API message as well if available.
Constructor Details
#initialize(response, message = nil) ⇒ ClientError
Extend client errors so that they annotate the response message with the details from a JSON response. LiquidPlanner sends back useful response bodies, so we might as well use them if they are available.
8 9 10 11 12 13 14 15 16 |
# File 'lib/liquidplanner/ext/exceptions.rb', line 8 def initialize(response, =nil) if ! && response['Content-Type']['application/json'] details = ActiveSupport::JSON.decode(response.body) = details['message'] super response, else super response, end end |
Instance Method Details
#to_s ⇒ Object
Return the default exception message with the extracted API message as well if available
19 20 21 22 23 |
# File 'lib/liquidplanner/ext/exceptions.rb', line 19 def to_s str = super str << " #{@message}" if @message str end |