diff options
author | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-11 11:25:09 +0000 |
---|---|---|
committer | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-11 11:25:09 +0000 |
commit | a651b0c9cc84d50e1eefd2ed728819a8f96c0b18 (patch) | |
tree | 403f91deaef699785045773045dc39541b21c1ce /lib/drb | |
parent | 2807bd47af467c866d717015bbff4a46000e59aa (diff) |
add DRbRemoteError. [ruby-list:40348], [ruby-list:40390]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/drb')
-rw-r--r-- | lib/drb/drb.rb | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb index c90259f87e..e92131f1d8 100644 --- a/lib/drb/drb.rb +++ b/lib/drb/drb.rb @@ -430,6 +430,15 @@ module DRb end end + class DRbRemoteError < DRbError + def initialize(error) + @reason = error.class.to_s + super("#{error.message} (#{error.class})") + set_backtrace(error.backtrace) + end + attr_reader :reason + end + # Class wrapping a marshalled object whose type is unknown locally. # # If an object is returned by a method invoked over drb, but the @@ -539,12 +548,12 @@ module DRb @argc_limit = config[:argc_limit] end - def dump(obj) # :nodoc: - obj = DRbObject.new(obj) if obj.kind_of? DRbUndumped + def dump(obj, error=false) # :nodoc: + obj = make_proxy(obj, error) if obj.kind_of? DRbUndumped begin str = Marshal::dump(obj) rescue - str = Marshal::dump(DRbObject.new(obj)) + str = Marshal::dump(make_proxy(obj, error)) end [str.size].pack('N') + str end @@ -602,7 +611,7 @@ module DRb end def send_reply(stream, succ, result) # :nodoc: - stream.write(dump(succ) + dump(result)) + stream.write(dump(succ) + dump(result, !succ)) rescue raise(DRbConnError, $!.message, $!.backtrace) end @@ -612,6 +621,15 @@ module DRb result = load(stream) [succ, result] end + + private + def make_proxy(obj, error=false) + if error + DRbRemoteError.new(obj) + else + DRbObject.new(obj) + end + end end # Module managing the underlying network protocol(s) used by drb. |