Changes the semantics of UnhandledError. First, it takes in a root
exception to wrap, rather than implicitly grabbing the last caught
exception. Second, it displays the root exception message instead
of wrapping it in a new message and only displaying the root cause
in a pre-collected traceback.

Signed-off-by: John Admanski <jadmanski@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@1710 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/common_lib/error.py b/client/common_lib/error.py
index 1fe3370..6052584 100644
--- a/client/common_lib/error.py
+++ b/client/common_lib/error.py
@@ -2,7 +2,7 @@
 Internal global error types
 """
 
-import sys
+import sys, traceback
 from traceback import format_exception
 
 def format_error():
@@ -69,9 +69,15 @@
 
 class UnhandledError(TestError):
     """Indicates an unhandled exception in a test."""
-    def __init__(self, prefix):
-        msg = prefix + format_error()
-        TestError.__init__(self, msg)
+    def __init__(self, unhandled_exception):
+        if isinstance(unhandled_exception, TestError):
+            TestError.__init__(self, *unhandled_exception.args)
+        else:
+            msg = "Unhandled %s: %s"
+            msg %= (unhandled_exception.__class__.__name__,
+                    unhandled_exception)
+            msg += "\n" + "\n".join(traceback.format_exc())
+            TestError.__init__(self, msg)
 
 
 class InstallError(JobError):