diff mbox

[KVM-AUTOTEST,v3,04/11] Embed context information in exception strings

Message ID 1294426091-16704-4-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Jan. 7, 2011, 6:48 p.m. UTC
None
diff mbox

Patch

diff --git a/client/common_lib/error.py b/client/common_lib/error.py
index b0e33b2..c3479bb 100644
--- a/client/common_lib/error.py
+++ b/client/common_lib/error.py
@@ -168,7 +168,8 @@  class JobComplete(SystemExit):
 
 class AutotestError(Exception):
     """The parent of all errors deliberatly thrown within the client code."""
-    pass
+    def __str__(self):
+        return Exception.__str__(self) + _context_message(self)
 
 
 class JobError(AutotestError):
@@ -190,6 +191,8 @@  class UnhandledJobError(JobError):
             msg = "Unhandled %s: %s"
             msg %= (self.unhandled_exception.__class__.__name__,
                     self.unhandled_exception)
+            if not isinstance(self.unhandled_exception, AutotestError):
+                msg += _context_message(self.unhandled_exception)
             msg += "\n" + self.traceback
             return msg
 
@@ -236,6 +239,8 @@  class UnhandledTestError(TestError):
             msg = "Unhandled %s: %s"
             msg %= (self.unhandled_exception.__class__.__name__,
                     self.unhandled_exception)
+            if not isinstance(self.unhandled_exception, AutotestError):
+                msg += _context_message(self.unhandled_exception)
             msg += "\n" + self.traceback
             return msg
 
@@ -254,6 +259,8 @@  class UnhandledTestFail(TestFail):
             msg = "Unhandled %s: %s"
             msg %= (self.unhandled_exception.__class__.__name__,
                     self.unhandled_exception)
+            if not isinstance(self.unhandled_exception, AutotestError):
+                msg += _context_message(self.unhandled_exception)
             msg += "\n" + self.traceback
             return msg
 
@@ -278,6 +285,7 @@  class CmdError(TestError):
 
         if self.additional_text:
             msg += ", " + self.additional_text
+        msg += _context_message(self)
         msg += '\n' + repr(self.result_obj)
         return msg