Exception: Aliyun::Log::ServerError
- Inherits:
-
StandardError
- Object
- StandardError
- Aliyun::Log::ServerError
- Defined in:
- lib/aliyun/log/server_error.rb
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.
-
#raw_message ⇒ Object
readonly
Returns the value of attribute raw_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.
- #message ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(response) ⇒ ServerError
Returns a new instance of ServerError.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/aliyun/log/server_error.rb', line 10 def initialize(response) @http_code = response.code body = JSON.parse(response.body) @error_code = body['errorCode'] @raw_message = body['errorMessage'] if @error_code == 'IndexInfoInvalid' human_info = ' please see the rules: ' \ 'https://help.aliyun.com/document_detail/74953.html' @raw_message += human_info end @request_id = response.headers['x-log-requestid'] end |
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
8 9 10 |
# File 'lib/aliyun/log/server_error.rb', line 8 def error_code @error_code end |
#http_code ⇒ Object (readonly)
Returns the value of attribute http_code.
8 9 10 |
# File 'lib/aliyun/log/server_error.rb', line 8 def http_code @http_code end |
#raw_message ⇒ Object (readonly)
Returns the value of attribute raw_message.
8 9 10 |
# File 'lib/aliyun/log/server_error.rb', line 8 def @raw_message end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
8 9 10 |
# File 'lib/aliyun/log/server_error.rb', line 8 def request_id @request_id end |
Instance Method Details
#message ⇒ Object
23 24 25 |
# File 'lib/aliyun/log/server_error.rb', line 23 def @raw_message || "UnknownError[#{http_code}]." end |
#to_s ⇒ Object
27 28 29 30 |
# File 'lib/aliyun/log/server_error.rb', line 27 def to_s msg = @raw_message || "UnknownError[#{http_code}]." "error_code: #{@error_code} message: #{msg} RequestId: #{request_id}" end |