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.



10
11
12
# File 'lib/fog/rackspace.rb', line 10

def response_data
  @response_data
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



10
11
12
# File 'lib/fog/rackspace.rb', line 10

def status_code
  @status_code
end

Class Method Details

.slurp(error) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/rackspace.rb', line 16

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



12
13
14
# File 'lib/fog/rackspace.rb', line 12

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