Class: Fog::UKCloud::Errors::ServiceError

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

Direct Known Subclasses

Unauthorised

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#status_codeObject (readonly)

Returns the value of attribute status_code.



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

def status_code
  @status_code
end

Class Method Details

.slurp(error, service = nil) ⇒ Object



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

def self.slurp(error, service=nil)
  status_code = nil
  if error.response
    status_code = error.response.status
    unless error.response.body.empty?
      begin
        document = Nokogiri::XML(error.response.body)
        message = document.xpath('//error').text
      rescue => e
        Fog::Logger.warning("Received exception '#{e}' while decoding>> #{error.response.body}")
        message = error.response.body
      end
    end
  end

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