DRb and exceptions

F

Ferenc Engard

Hi all,

The drb documentation says that I can raise exceptions in a remote
object method and the exception is marshaled to the calling side.

Unfortunately this do not work for me. If any exception is raised in a
remote object, I get the following exception in the calling process:

c:/ruby/lib/ruby/1.8/drb/drb.rb:558:in `load': connection closed
(DRb::DRbConnError)
from c:/ruby/lib/ruby/1.8/drb/drb.rb:611:in `recv_reply'
from c:/ruby/lib/ruby/1.8/drb/drb.rb:865:in `recv_reply'
from c:/ruby/lib/ruby/1.8/drb/drb.rb:1104:in `send_message'
from c:/ruby/lib/ruby/1.8/drb/drb.rb:1015:in `method_missing'
from c:/ruby/lib/ruby/1.8/drb/drb.rb:1014:in `open'
from c:/ruby/lib/ruby/1.8/drb/drb.rb:1014:in `method_missing'
from chaos.rb:27:in `initialize'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here I called a remote method

What do I do wrong?

Thanks:
Ferenc
 
E

Eric Hodel

Hi all,

The drb documentation says that I can raise exceptions in a remote
object method and the exception is marshaled to the calling side.

Unfortunately this do not work for me. If any exception is raised in a
remote object, I get the following exception in the calling process:
[snip]

What do I do wrong?

What's your code?

This works:

$ cat exc.rb
require 'drb'

PATH = 'druby://localhost:9000'

class Raiser
def do_raise
raise RuntimeError, "Here we go!"
end
end

case ARGV.shift
when 'client'
raiser = DRbObject.new nil, PATH
raiser.do_raise
when 'server'
DRb.start_service PATH, Raiser.new
trap 'INT' do exit end
DRb.thread.join
else
STDERR.puts "#{$0} client|server"
exit 1
end

$ ruby exc.rb server &
[1] 3710
$ ruby exc.rb client
(druby://localhost:9000) exc.rb:7:in `do_raise': Here we go!
(RuntimeError)
from exc.rb:14
 
F

Ferenc Engard

The drb documentation says that I can raise exceptions in a remote
object method and the exception is marshaled to the calling side.

Unfortunately this do not work for me. If any exception is raised in a
remote object, I get the following exception in the calling process:
[snip]

What do I do wrong?

What's your code?
[...]
raise RuntimeError, "Here we go!"
[...]

Thank you, I have recognised my problem: the exception I raised was not
a StandardError descendant.

Anyway, there are not too much documentation about standard exception
classes, and its handling, but I have realized that only StandardError
and its descendants I catched by a simple 'rescue'. So I have to make my
own exceptions a subclass of StandardError instead of Exception.

Thanks again!
Ferenc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

drb works on one system fails on other 2
drb load limit 3
DRbFire testing fails 2
trying to get drb to work ... 0
dchat 0
Interaction of debug.h and DRb 0
DRb Problems with Mac OS X 10.5.3 21
error message help 1

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top