From patchwork Mon Jan 3 18:34:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 448901 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p03IXixs027593 for ; Mon, 3 Jan 2011 18:33:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754474Ab1ACSdk (ORCPT ); Mon, 3 Jan 2011 13:33:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49690 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754594Ab1ACSdj (ORCPT ); Mon, 3 Jan 2011 13:33:39 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p03IXchj008909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 3 Jan 2011 13:33:39 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p03IXcVD007482; Mon, 3 Jan 2011 13:33:38 -0500 Received: from moof.tlv.redhat.com (dhcp-1-185.tlv.redhat.com [10.35.1.185]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p03IXWvw027804; Mon, 3 Jan 2011 13:33:37 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 4/7] [RFC] Embed context information in exception strings Date: Mon, 3 Jan 2011 20:34:08 +0200 Message-Id: <1294079651-21631-4-git-send-email-mgoldish@redhat.com> In-Reply-To: <1294079651-21631-1-git-send-email-mgoldish@redhat.com> References: <1294079651-21631-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 03 Jan 2011 18:33:45 +0000 (UTC) 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