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

Returns a new instance of Error.



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

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.



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

def response_code
  @response_code
end

#response_msgObject (readonly)

Returns the value of attribute response_msg.



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

def response_msg
  @response_msg
end

#rpc_errorObject (readonly)

Returns the value of attribute rpc_error.



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

def rpc_error
  @rpc_error
end

Instance Method Details

#messageString

Return string that represents error message.

Returns:



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

def message
  response.to_json
end

#responseHash

Return response object as Hash

Parameters:

  • response_code (Hash)

    a customizable set of options

  • response_msg (Hash)

    a customizable set of options

  • rpc_error (Hash)

    a customizable set of options

Returns:

  • (Hash)

    response



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

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



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

def to_s
  message
end