Skip to content

Commit

Permalink
Trying to avoid the unhelpful errors when examples toss exceptions.
Browse files Browse the repository at this point in the history
The problem occurs when the client side lacks the class of the
exception tossed by the server.

Also don't think we need to fail_filtered_examples on the client since
the server already did it.
  • Loading branch information
jcrossley3 committed Nov 8, 2011
1 parent 5726980 commit 2e5b501
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions lib/torquespec/daemon.rb
Expand Up @@ -80,8 +80,6 @@ def run(reporter)
begin begin
torquespec_before_alls torquespec_before_alls
run_remotely(reporter) run_remotely(reporter)
rescue Exception => ex
fail_filtered_examples(ex, reporter)
ensure ensure
torquespec_after_alls torquespec_after_alls
end end
Expand Down Expand Up @@ -139,17 +137,44 @@ def marshal_load *args
end end
end end


# We want any Java exceptions tossed on the server to be passed back # We want exceptions tossed in the container to be passed back to the
# to the Reporter on the client, and NativeExceptions have no # client, but there's no guarantee the type of Exception in the
# allocator, hence they're not marshalable. # container will be available on the client's classpath, so we turn
class NativeException # all exceptions into Exceptions.
def _dump(*) module TorqueSpec
Marshal.dump( [cause, backtrace] ) def self.dump(exception)
Marshal.dump( [exception.message, exception.backtrace] )
end end
def self._load(str) def self.load_exception(str)
exception, trace = Marshal.load(str) message, trace = Marshal.load(str)
exception = ::Exception.new(message)
meta = class << exception; self; end meta = class << exception; self; end
meta.send(:define_method, :backtrace) { trace } meta.send(:define_method, :backtrace) { trace }
exception exception
end end
end end

# For ruby exceptions...
class Exception
def _dump(*)
TorqueSpec.dump(self)
end
def self._load(str)
TorqueSpec.load_exception(str)
end
end

# And for java exceptions, too.
module Java
module JavaLang
class Exception
def _dump(*)
TorqueSpec.dump(self)
end
def self._load(str)
TorqueSpec.load_exception(str)
end
end
end
end

0 comments on commit 2e5b501

Please sign in to comment.