From patchwork Wed Jan 5 15:45:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 453761 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 p05FjOuD016604 for ; Wed, 5 Jan 2011 15:45:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751879Ab1AEPpU (ORCPT ); Wed, 5 Jan 2011 10:45:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28262 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751757Ab1AEPpS (ORCPT ); Wed, 5 Jan 2011 10:45:18 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p05FjI6D015785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 5 Jan 2011 10:45:18 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p05FjHvS026232; Wed, 5 Jan 2011 10:45:17 -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 p05FjBQJ027486; Wed, 5 Jan 2011 10:45:16 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH v2 4/6] [RFC] Embed context information in exception strings Date: Wed, 5 Jan 2011 17:45:27 +0200 Message-Id: <1294242329-11034-4-git-send-email-mgoldish@redhat.com> In-Reply-To: <1294242329-11034-1-git-send-email-mgoldish@redhat.com> References: <1294242329-11034-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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]); Wed, 05 Jan 2011 15:45:26 +0000 (UTC) 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