Exception: Farcall::RemoteError

Inherits:
Error
  • Object
show all
Defined in:
lib/farcall/transport.rb

Overview

The error occured while executin remote method. Inf an exception is raused while executing remote method, it will be passed back and raised in the caller thread with an instance of this class.

The remote can throw regular or extended errors. Extended errors can pass any data to the other end, which will be available as #data.

To carry error data just raise any exception which respnd_to(:data), which should return hash with any application specific error data, as in this sample error class:

class MyError < StandardError
    def data
      { foo: bar }
    end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote_class, text, data = {}) ⇒ RemoteError

Returns a new instance of RemoteError.



29
30
31
32
# File 'lib/farcall/transport.rb', line 29

def initialize remote_class, text, data={}
  @remote_class, @data = remote_class, data
  super "#{remote_class}: #{text}"
end

Instance Attribute Details

#dataObject (readonly)

data passed by the remote error or an empty hash



27
28
29
# File 'lib/farcall/transport.rb', line 27

def data
  @data
end

#remote_classObject (readonly)

The class of the remote error. Usually string name of the class or any other useful string identifier.



25
26
27
# File 'lib/farcall/transport.rb', line 25

def remote_class
  @remote_class
end