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 strgin) nothing is embedded. Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx> --- client/common_lib/error.py | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/client/common_lib/error.py b/client/common_lib/error.py index 394f555..ed7132e 100644 --- a/client/common_lib/error.py +++ b/client/common_lib/error.py @@ -111,7 +111,14 @@ class JobComplete(SystemExit): class AutotestError(Exception): """The parent of all errors deliberatly thrown within the client code.""" - pass + def context_str(self): + if hasattr(self, "context") and self.context: + return " [context: %s]" % self.context + else: + return "" + + def __str__(self): + return Exception.__str__(self) + self.context_str() class JobError(AutotestError): @@ -133,6 +140,7 @@ class UnhandledJobError(JobError): msg = "Unhandled %s: %s" msg %= (self.unhandled_exception.__class__.__name__, self.unhandled_exception) + msg += self.context_str() msg += "\n" + self.traceback return msg @@ -179,6 +187,7 @@ class UnhandledTestError(TestError): msg = "Unhandled %s: %s" msg %= (self.unhandled_exception.__class__.__name__, self.unhandled_exception) + msg += self.context_str() msg += "\n" + self.traceback return msg @@ -197,6 +206,7 @@ class UnhandledTestFail(TestFail): msg = "Unhandled %s: %s" msg %= (self.unhandled_exception.__class__.__name__, self.unhandled_exception) + msg += self.context_str() msg += "\n" + self.traceback return msg @@ -221,6 +231,7 @@ class CmdError(TestError): if self.additional_text: msg += ", " + self.additional_text + msg += self.context_str() 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