Class: Fog::OpenStack::Errors::ServiceError

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

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.



5
6
7
# File 'lib/fog/openstack/errors.rb', line 5

def response_data
  @response_data
end

Class Method Details

.slurp(error) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/openstack/errors.rb', line 7

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

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