Method: Aliyun::STS::ServerError#initialize

Defined in:
lib/aliyun/sts/exception.rb

#initialize(response) ⇒ ServerError

Returns a new instance of ServerError.



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

def initialize(response)
  @http_code = response.code
  @attrs = {}

  doc = Nokogiri::XML(response.body) do |config|
    config.options |= Nokogiri::XML::ParseOptions::NOBLANKS
  end rescue nil

  if doc and doc.root
    doc.root.children.each do |n|
      @attrs[n.name] = n.text
    end
  end

  @error_code = @attrs['Code']
  @message = @attrs['Message']
  @request_id = @attrs['RequestId']
end