Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id F0204431FD0 for ; Sun, 25 Sep 2011 18:06:20 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4fcheKRC21b6 for ; Sun, 25 Sep 2011 18:06:20 -0700 (PDT) Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7FC21431FB6 for ; Sun, 25 Sep 2011 18:06:20 -0700 (PDT) Received: from mail.jade-hamburg.de (unknown [85.183.11.228]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cryptobitch.de (Postfix) with ESMTPSA id 5F92B505B23 for ; Mon, 26 Sep 2011 03:06:19 +0200 (CEST) Received: by mail.jade-hamburg.de (Postfix, from userid 401) id CFDC2DF2A7; Mon, 26 Sep 2011 03:06:18 +0200 (CEST) Received: from thinkbox.jade-hamburg.de (unknown [10.1.1.109]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: teythoon) by mail.jade-hamburg.de (Postfix) with ESMTPSA id D3B90DF28B; Mon, 26 Sep 2011 03:06:11 +0200 (CEST) Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.76) (envelope-from ) id 1R7ze4-0007OG-To; Mon, 26 Sep 2011 03:06:08 +0200 From: Justus Winter <4winter@informatik.uni-hamburg.de> To: notmuch@notmuchmail.org Subject: [PATCH 2/9] python: add status and message attributes to NotmuchError Date: Mon, 26 Sep 2011 03:05:30 +0200 Message-Id: <1316999137-28257-2-git-send-email-4winter@informatik.uni-hamburg.de> X-Mailer: git-send-email 1.7.6.3 In-Reply-To: <1316999137-28257-1-git-send-email-4winter@informatik.uni-hamburg.de> References: <1316999137-28257-1-git-send-email-4winter@informatik.uni-hamburg.de> X-Mailman-Approved-At: Mon, 26 Sep 2011 09:17:56 -0700 Cc: Justus Winter <4winter@informatik.uni-hamburg.de> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Sep 2011 01:06:21 -0000 Providing exception objects with meaningful attribute names is much nicer than using e.args[]. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de> --- bindings/python/notmuch/globals.py | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py index 05b9962..779ba5f 100644 --- a/bindings/python/notmuch/globals.py +++ b/bindings/python/notmuch/globals.py @@ -91,13 +91,14 @@ STATUS.__name__ = 'STATUS' class NotmuchError(Exception): def __init__(self, status=None, message=None): """Is initiated with a (notmuch.STATUS[,message=None])""" - super(NotmuchError, self).__init__(message, status) + self.status = status + self.message = message def __str__(self): - if self.args[0] is not None: - return self.args[0] + if self.message is not None: + return self.message else: - return STATUS.status2str(self.args[1]) + return STATUS.status2str(self.status) def _str(value): """Ensure a nicely utf-8 encoded string to pass to libnotmuch -- 1.7.6.3