Exception: Fountain::UnexpectedHTTPError

Inherits:
HTTPError show all
Defined in:
lib/fountain.rb

Overview

Unexpected HTTP Error

Instance Method Summary collapse

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_bodyObject



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_codeObject



31
32
33
# File 'lib/fountain.rb', line 31

def response_code
  @response.code
end

#response_messageObject



41
42
43
44
# File 'lib/fountain.rb', line 41

def response_message
  body = parsed_body
  body['message'] if body.is_a? Hash
end