Permalink
Browse files

Trying to avoid the unhelpful errors when examples toss exceptions.

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 2e5b50147e99536c8e85b7b8b172562dd0f76feb
Showing with 35 additions and 10 deletions.
  1. +35 −10 lib/torquespec/daemon.rb
View
@@ -80,8 +80,6 @@ def run(reporter)
begin
torquespec_before_alls
run_remotely(reporter)
- rescue Exception => ex
- fail_filtered_examples(ex, reporter)
ensure
torquespec_after_alls
end
@@ -139,17 +137,44 @@ def marshal_load *args
end
end
-# We want any Java exceptions tossed on the server to be passed back
-# to the Reporter on the client, and NativeExceptions have no
-# allocator, hence they're not marshalable.
-class NativeException
- def _dump(*)
- Marshal.dump( [cause, backtrace] )
+# We want exceptions tossed in the container to be passed back to the
+# client, but there's no guarantee the type of Exception in the
+# container will be available on the client's classpath, so we turn
+# all exceptions into Exceptions.
+module TorqueSpec
+ def self.dump(exception)
+ Marshal.dump( [exception.message, exception.backtrace] )
end
- def self._load(str)
- exception, trace = Marshal.load(str)
+ def self.load_exception(str)
+ message, trace = Marshal.load(str)
+ exception = ::Exception.new(message)
meta = class << exception; self; end
meta.send(:define_method, :backtrace) { trace }
exception
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.