Exception: Fog::HP::Errors::ServiceError

Inherits:
Errors::Error
  • Object
show all
Defined in:
lib/fog/hp/core.rb

Instance Attribute Summary collapse

Attributes inherited from Errors::Error

#verbose

Class Method Summary collapse

Instance Attribute Details

#response_dataObject (readonly)

Returns the value of attribute response_data.



16
17
18
# File 'lib/fog/hp/core.rb', line 16

def response_data
  @response_data
end

Class Method Details

.slurp(error) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/hp/core.rb', line 18

def self.slurp(error)
  if error.response.body.empty?
    data = nil
    message = nil
  else
    begin
      data = Fog::JSON.decode(error.response.body)
      message = data['message']
      if message.nil? and !data.values.first.nil?
        message = data.values.first['message']
      end
    rescue Fog::JSON::DecodeError
      message = error.response.body  #### body is not in JSON format, so just return as is
    end
  end

  new_error = super(error, message)
  new_error.instance_variable_set(:@response_data, data)
  new_error
end