Class: Aliyun::Opensearch::Error::AliyunService

Inherits:
HttpBase
  • Object
show all
Defined in:
lib/aliyun/opensearch/error.rb

Overview

阿里云异常基类

Author:

Constant Summary collapse

ERRCODE_ALIYUN_SYS =

系统级别(1000-1999)

(1000..1999).freeze
ERRCODE_ALIYUN_APP =

应用相关(2000-2999)

(2000..2999).freeze
ERRCODE_ALIYUN_DOC =

文档相关(3000-3999)

(3000..3999).freeze
ERRCODE_ALIYUN_AUTH =

授权相关(4000-4999)

(4000..4999).freeze
ERRCODE_ALIYUN_USER =

用户相关(5000-5999)

(5000..5999).freeze
ERRCODE_ALIYUN_SEARCH =

搜索相关(6000-6999)

(6000..6999).freeze
ERRCODE_ALIYUN_CMD =

数据处理相关(7000-7999)

(7000..7999).freeze
ERRCODE_ALIYUN_COMMON =

文档错误内部通知(8000-8999)

(8000..8999).freeze
ERRCODE_ALIYUN_TEMPLETE =

模板相关(9000-9999)

(9000..9999).freeze
ERRCODE_ALIYUN_SYNC =

数据同步相关(10000-)

(10_000..).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ AliyunService

初始化

Parameters:

  • response (Faraday::Response)

    接口返回结果

Author:



45
46
47
48
49
50
# File 'lib/aliyun/opensearch/error.rb', line 45

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

  super("RequestId:#{@body['request_id']} Message:#{errors_message}", response)
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



36
37
38
# File 'lib/aliyun/opensearch/error.rb', line 36

def response
  @response
end

Instance Method Details

#errors_messageString

获取错误信息

Returns:

  • (String)

    错误消息

Author:



59
60
61
62
63
# File 'lib/aliyun/opensearch/error.rb', line 59

def errors_message
  @body['errors'].map do |error|
    "[#{error['code']}] #{error['message']}"
  end.join("\n")
end