Skip to content

Commit

Permalink
promote exception traceback from the remote actor to the local node
Browse files Browse the repository at this point in the history
  • Loading branch information
niamster committed Mar 22, 2015
1 parent feac404 commit f2badfa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/dcell/actor_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions lib/dcell/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions lib/dcell/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f2badfa

Please sign in to comment.