Exceptions look for a ._context attribute and embed it in the string returned by __str__(). If the attribute isn't set (or if it's an empty string) nothing is embedded. Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx> --- client/common_lib/error.py | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/client/common_lib/error.py b/client/common_lib/error.py index 952f977..ff22d84 100644 --- a/client/common_lib/error.py +++ b/client/common_lib/error.py @@ -126,7 +126,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): @@ -148,6 +149,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 @@ -194,6 +197,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 @@ -212,6 +217,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 @@ -236,6 +243,7 @@ class CmdError(TestError): if self.additional_text: msg += ", " + self.additional_text + msg += _context_message(self) msg += '\n' + repr(self.result_obj) return msg -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html