Exception: Aliyun::STS::ServerError
- Inherits:
-
Common::Exception
- Object
- RuntimeError
- Common::Exception
- Aliyun::STS::ServerError
- Defined in:
- lib/aliyun/sts/exception.rb
Overview
ServerError represents exceptions from the STS 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 STS request id.
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.
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. |= 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.
14 15 16 |
# File 'lib/aliyun/sts/exception.rb', line 14 def error_code @error_code end |
#http_code ⇒ Object (readonly)
Returns the value of attribute http_code.
14 15 16 |
# File 'lib/aliyun/sts/exception.rb', line 14 def http_code @http_code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
14 15 16 |
# File 'lib/aliyun/sts/exception.rb', line 14 def @message end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
14 15 16 |
# File 'lib/aliyun/sts/exception.rb', line 14 def request_id @request_id end |
Instance Method Details
#to_s ⇒ Object
40 41 42 43 44 |
# File 'lib/aliyun/sts/exception.rb', line 40 def to_s @attrs.merge({'HTTPCode' => @http_code}).map do |k, v| [k, v].join(": ") end.join(", ") end |