Exception: Tapyrus::RPC::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/tapyrus/rpc/tapyrus_core_client.rb

Overview

Throw when happened anything http’s error with connect to server.

Almost case this exception happened from 401 Unauthorized or 500 Internal Server Error. And also, throw by cause of other http’s errors.

You can pull RPC error message when happened 500 Internal Server Error, like below:

rescue Tapyrus::RPC::Error => ex

if ex.message.response_code == 500
  puts ex.message[:rpc_error]
end

end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_code, response_msg, rpc_error) ⇒ Error



20
21
22
23
24
# File 'lib/tapyrus/rpc/tapyrus_core_client.rb', line 20

def initialize(response_code, response_msg, rpc_error)
  @response_code = response_code
  @response_msg = response_msg
  @rpc_error = rpc_error
end

Instance Attribute Details

#response_codeObject (readonly)

Returns the value of attribute response_code.



18
19
20
# File 'lib/tapyrus/rpc/tapyrus_core_client.rb', line 18

def response_code
  @response_code
end

#response_msgObject (readonly)

Returns the value of attribute response_msg.



18
19
20
# File 'lib/tapyrus/rpc/tapyrus_core_client.rb', line 18

def response_msg
  @response_msg
end

#rpc_errorObject (readonly)

Returns the value of attribute rpc_error.



18
19
20
# File 'lib/tapyrus/rpc/tapyrus_core_client.rb', line 18

def rpc_error
  @rpc_error
end

Instance Method Details

#messageString

Return string that represents error message.



42
43
44
# File 'lib/tapyrus/rpc/tapyrus_core_client.rb', line 42

def message
  response.to_json
end

#responseHash

Return response object as Hash



31
32
33
34
35
36
37
38
# File 'lib/tapyrus/rpc/tapyrus_core_client.rb', line 31

def response
  @response ||=
    begin
      m = { response_code: response_code, response_msg: response_msg }
      m.merge!(rpc_error: rpc_error) if rpc_error
      m
    end
end

#to_sObject



46
47
48
# File 'lib/tapyrus/rpc/tapyrus_core_client.rb', line 46

def to_s
  message
end