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.



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

def response_data
  @response_data
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



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

def status_code
  @status_code
end

Class Method Details

.slurp(error) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/rackspace.rb', line 21

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

  if error.response
    status_code = error.response.status
    unless error.response.body.empty?
      begin
        data = Fog::JSON.decode(error.response.body)
        message = data.values.first ? data.values.first['message'] : data['message']
      rescue  => e
        Fog::Logger.warning("Received exception '#{e}' while decoding>> #{error.response.body}")
        message = error.response.body
        data = error.response.body
      end
    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



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

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