Exception: Wire::WireError

Inherits:
Error
  • Object
show all
Defined in:
lib/wire/errors.rb

Overview

WireError is a typed error decoded from the API error envelope ({ “error”: { … } }). It is raised for any non-2xx API response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, type: "api_error", code: nil, param: nil, request_id: nil, doc_url: nil, operator_decline_code: nil, status_code: nil) ⇒ WireError

Returns a new instance of WireError.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/wire/errors.rb', line 15

def initialize(message, type: "api_error", code: nil, param: nil,
               request_id: nil, doc_url: nil, operator_decline_code: nil,
               status_code: nil)
  super(message)
  @type = type
  @code = code
  @param = param
  @request_id = request_id
  @doc_url = doc_url
  @operator_decline_code = operator_decline_code
  @status_code = status_code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



12
13
14
# File 'lib/wire/errors.rb', line 12

def code
  @code
end

#doc_urlObject (readonly)

Returns the value of attribute doc_url.



12
13
14
# File 'lib/wire/errors.rb', line 12

def doc_url
  @doc_url
end

#operator_decline_codeObject (readonly)

Returns the value of attribute operator_decline_code.



12
13
14
# File 'lib/wire/errors.rb', line 12

def operator_decline_code
  @operator_decline_code
end

#paramObject (readonly)

Returns the value of attribute param.



12
13
14
# File 'lib/wire/errors.rb', line 12

def param
  @param
end

#request_idObject (readonly)

Returns the value of attribute request_id.



12
13
14
# File 'lib/wire/errors.rb', line 12

def request_id
  @request_id
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



12
13
14
# File 'lib/wire/errors.rb', line 12

def status_code
  @status_code
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/wire/errors.rb', line 12

def type
  @type
end

Instance Method Details

#to_sObject



28
29
30
31
# File 'lib/wire/errors.rb', line 28

def to_s
  "#{super} (type=#{type}, code=#{code}, status=#{status_code}, " \
    "request_id=#{request_id})"
end