Exception: Fountain::UnexpectedHTTPError
- Defined in:
- lib/fountain.rb
Overview
Unexpected HTTP Error
Instance Method Summary collapse
-
#initialize(response) ⇒ UnexpectedHTTPError
constructor
A new instance of UnexpectedHTTPError.
- #parsed_body ⇒ Object
- #response_code ⇒ Object
- #response_message ⇒ Object
Constructor Details
#initialize(response) ⇒ UnexpectedHTTPError
Returns a new instance of UnexpectedHTTPError.
26 27 28 29 |
# File 'lib/fountain.rb', line 26 def initialize(response) @response = response super("Unexpected http response code: #{response.code}") end |
Instance Method Details
#parsed_body ⇒ Object
35 36 37 38 39 |
# File 'lib/fountain.rb', line 35 def parsed_body JSON.parse(@response.body) rescue JSON::ParserError @response.body end |
#response_code ⇒ Object
31 32 33 |
# File 'lib/fountain.rb', line 31 def response_code @response.code end |
#response_message ⇒ Object
41 42 43 44 |
# File 'lib/fountain.rb', line 41 def body = parsed_body body['message'] if body.is_a? Hash end |