Class: Tidepool::ErrorMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/tidepool/error_message.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ErrorMessage

Returns a new instance of ErrorMessage.



3
4
5
6
# File 'lib/tidepool/error_message.rb', line 3

def initialize(response)
  @response = response
  @base_message = "Error #{response.code}"
end

Instance Method Details

#messageObject



8
9
10
11
12
13
14
# File 'lib/tidepool/error_message.rb', line 8

def message
  if tidepool_message
    "#{base_message} #{tidepool_message}"
  else
    base_message
  end
end

#tidepool_messageObject



16
17
18
# File 'lib/tidepool/error_message.rb', line 16

def tidepool_message
  response["reason"] || response["message"]
end