class AliyunSDK::OSS::ServerError
ServerError
represents exceptions from the OSS
service. i.e. Client
receives a HTTP
response whose status is NOT OK. message
provides the error message and to_s
gives detailed information probably including the OSS
request id.
Attributes
error_code[R]
http_code[R]
message[R]
request_id[R]
Public Class Methods
new(response)
click to toggle source
# File lib/aliyun_sdk/oss/exception.rb, line 17 def initialize(response) @http_code = response.code @attrs = {'RequestId' => get_request_id(response)} 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
Public Instance Methods
to_s()
click to toggle source
# File lib/aliyun_sdk/oss/exception.rb, line 41 def to_s @attrs.merge({'HTTPCode' => @http_code}).map do |k, v| [k, v].join(": ") end.join(", ") end
Private Instance Methods
get_request_id(response)
click to toggle source
# File lib/aliyun_sdk/oss/exception.rb, line 49 def get_request_id(response) r = response.headers[:x_oss_request_id] if response.headers r.to_s end