Exception: Aliyun::OSS::ServerError
- Inherits:
-
Common::Exception
- Object
- RuntimeError
- Common::Exception
- Aliyun::OSS::ServerError
- Defined in:
- lib/aliyun/oss/exception.rb
Overview
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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#http_code ⇒ Object
readonly
Returns the value of attribute http_code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
Instance Method Summary collapse
-
#initialize(response) ⇒ ServerError
constructor
A new instance of ServerError.
- #to_s ⇒ Object
Constructor Details
#initialize(response) ⇒ ServerError
Returns a new instance of ServerError.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/aliyun/oss/exception.rb', line 18 def initialize(response) @http_code = response.code @attrs = {'RequestId' => get_request_id(response)} doc = Nokogiri::XML(response.body) do |config| config. |= 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 |
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
16 17 18 |
# File 'lib/aliyun/oss/exception.rb', line 16 def error_code @error_code end |
#http_code ⇒ Object (readonly)
Returns the value of attribute http_code.
16 17 18 |
# File 'lib/aliyun/oss/exception.rb', line 16 def http_code @http_code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
16 17 18 |
# File 'lib/aliyun/oss/exception.rb', line 16 def @message end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
16 17 18 |
# File 'lib/aliyun/oss/exception.rb', line 16 def request_id @request_id end |
Instance Method Details
#to_s ⇒ Object
42 43 44 45 46 |
# File 'lib/aliyun/oss/exception.rb', line 42 def to_s @attrs.merge({'HTTPCode' => @http_code}).map do |k, v| [k, v].join(": ") end.join(", ") end |