Class: Fog::Proxmox::Errors::ServiceError

Inherits:
Errors::Error
  • Object
show all
Defined in:
lib/fog/proxmox/errors.rb

Overview

class ServiceError

Direct Known Subclasses

BadRequest, ServiceUnavailable

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#response_dataObject (readonly)

Returns the value of attribute response_data


25
26
27
# File 'lib/fog/proxmox/errors.rb', line 25

def response_data
  @response_data
end

Class Method Details

.slurp(error) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/proxmox/errors.rb', line 27

def self.slurp(error)
  if error.response.body.empty?
    data = nil
    message = nil
  else
    data = Fog::JSON.decode(error.response.body)
    message = data['message']
    data1 = data.values.first
    message = data1['message'] if message.nil? && !data1.nil?
  end

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