Exception: Aliyun::Log::ServerError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/aliyun/log/server_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_codeObject (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_codeObject (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_messageObject (readonly)

Returns the value of attribute raw_message.



8
9
10
# File 'lib/aliyun/log/server_error.rb', line 8

def raw_message
  @raw_message
end

#request_idObject (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

#messageObject



23
24
25
# File 'lib/aliyun/log/server_error.rb', line 23

def message
  @raw_message || "UnknownError[#{http_code}]."
end

#to_sObject



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