Exception: Fog::Rackspace::Errors::ServiceError

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

Instance Attribute Summary collapse

Attributes inherited from Errors::Error

#verbose

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#response_dataObject (readonly)

Returns the value of attribute response_data.



14
15
16
# File 'lib/fog/rackspace.rb', line 14

def response_data
  @response_data
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



14
15
16
# File 'lib/fog/rackspace.rb', line 14

def status_code
  @status_code
end

Class Method Details

.slurp(error) ⇒ Object



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

def self.slurp(error)
  data = nil
  message = nil
  status_code = nil

  if error.response
    status_code = error.response.status
    unless error.response.body.empty?
      data = Fog::JSON.decode(error.response.body)
      message = data.values.first ? data.values.first['message'] : data['message']
    end
  end

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

Instance Method Details

#to_sObject



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

def to_s
  status_code ? "[HTTP #{status_code}] #{super}" : super
end