Exception: COS::ServerError

Inherits:
Exception
  • Object
show all
Defined in:
lib/cos/exception.rb

Overview

服务端返回异常 Code: -166, Message: 索引不存在, HttpCode: 400 Code: -173, Message: 目录非空, HttpCode: 400 Code: -180, Message: 非法路径, HttpCode: 400 Code: -288, Message: process打包失败, HttpCode: 400 Code: -4018, Message: 相同文件已上传过, HttpCode: 400 Code: -5997, Message: 后端网络错误, HttpCode: 400 Code: -5999, Message: 参数错误, HttpCode: 400

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ServerError

Returns a new instance of ServerError.



22
23
24
25
26
27
28
29
# File 'lib/cos/exception.rb', line 22

def initialize(response)
  @response = response
  resp_obj  = JSON.parse(response.body)

  @error_code = resp_obj['code']
  @message    = resp_obj['message']
  @http_code  = response.code
end

Instance Attribute Details

#error_codeObject (readonly)

Returns the value of attribute error_code.



20
21
22
# File 'lib/cos/exception.rb', line 20

def error_code
  @error_code
end

#http_codeObject (readonly)

Returns the value of attribute http_code.



20
21
22
# File 'lib/cos/exception.rb', line 20

def http_code
  @http_code
end

#messageObject (readonly)

Returns the value of attribute message.



20
21
22
# File 'lib/cos/exception.rb', line 20

def message
  @message
end

#responseObject (readonly)

Returns the value of attribute response.



20
21
22
# File 'lib/cos/exception.rb', line 20

def response
  @response
end

Instance Method Details

#to_sObject



35
36
37
# File 'lib/cos/exception.rb', line 35

def to_s
  "ServerError Code: #{error_code}, Message: #{message}, HttpCode: #{http_code}"
end