diff --git a/lib/dcell/actor_proxy.rb b/lib/dcell/actor_proxy.rb index 3e17170..d44f221 100644 --- a/lib/dcell/actor_proxy.rb +++ b/lib/dcell/actor_proxy.rb @@ -26,7 +26,7 @@ def ______any_method_missing(handler, meth, *args, &block) rescue AbortError => e cause = e.cause raise Celluloid::DeadActorError.new if cause.kind_of? Celluloid::DeadActorError - raise RuntimeError, cause + raise RuntimeError, cause, cause.backtrace end def ______method_missing(meth, *args, &block) diff --git a/lib/dcell/messages.rb b/lib/dcell/messages.rb index d69e5b9..449063b 100644 --- a/lib/dcell/messages.rb +++ b/lib/dcell/messages.rb @@ -20,6 +20,10 @@ def respond(rsp) __respond rsp, :response end + def exception(e) + respond ErrorResponse.new(id, @sender[:address], {class: e.class.name, msg: e.to_s, tb: e.backtrace}) + end + # A request to open relay pipe class RelayOpen < Message def initialize(sender) @@ -33,7 +37,7 @@ def dispatch respond SuccessResponse.new(id, @sender[:address], node.rserver.addr) rescue => e # :nocov: - respond ErrorResponse.new(id, @sender[:address], {class: e.class.name, msg: e.to_s}) + exception e # :nocov: end @@ -168,16 +172,12 @@ def success(value) respond SuccessResponse.new(id, @sender[:address], value) end - def exception(e) - respond ErrorResponse.new(id, @sender[:address], {class: e.class.name, msg: e.to_s}) - end - def dispatch actor = DCell.get_local_actor @message[:actor].to_sym begin actor.async :____dcell_dispatch, self rescue => e - respond ErrorResponse.new(id, @sender[:address], {class: e.class.name, msg: e.to_s}) + exception e end end diff --git a/lib/dcell/node.rb b/lib/dcell/node.rb index abb80b6..7344bd2 100644 --- a/lib/dcell/node.rb +++ b/lib/dcell/node.rb @@ -188,9 +188,11 @@ def send_request(request, pipe=:request, timeout=nil) response = push_request request, pipe, timeout return if response.is_a? CancelResponse if response.is_a? ErrorResponse - klass = Utils::full_const_get response.value[:class] - msg = response.value[:msg] - abort klass.new msg + value = response.value + klass = Utils::full_const_get value[:class] + exception = klass.new value[:msg] + exception.set_backtrace value[:tb] + abort exception end response.value end