--- /dev/null
+Return-Path: <teythoon@jade-hamburg.de>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 27432429E21\r
+ for <notmuch@notmuchmail.org>; Sun, 25 Sep 2011 18:06:42 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id bL8CmSzLNKQ3 for <notmuch@notmuchmail.org>;\r
+ Sun, 25 Sep 2011 18:06:41 -0700 (PDT)\r
+Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68])\r
+ (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 4B663431FD0\r
+ for <notmuch@notmuchmail.org>; Sun, 25 Sep 2011 18:06:41 -0700 (PDT)\r
+Received: from mail.jade-hamburg.de (unknown [85.183.11.228])\r
+ (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by mail.cryptobitch.de (Postfix) with ESMTPSA id 1A61A505B24\r
+ for <notmuch@notmuchmail.org>; Mon, 26 Sep 2011 03:06:40 +0200 (CEST)\r
+Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
+ id 91800DF2A1; Mon, 26 Sep 2011 03:06:39 +0200 (CEST)\r
+Received: from thinkbox.jade-hamburg.de (unknown [10.1.1.109])\r
+ (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
+ (No client certificate requested) (Authenticated sender: teythoon)\r
+ by mail.jade-hamburg.de (Postfix) with ESMTPSA id 71B71DF2A3;\r
+ Mon, 26 Sep 2011 03:06:14 +0200 (CEST)\r
+Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.76)\r
+ (envelope-from <teythoon@thinkbox.jade-hamburg.de>)\r
+ id 1R7ze5-0007OV-Lt; Mon, 26 Sep 2011 03:06:09 +0200\r
+From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 7/9] python: provide more exception classes\r
+Date: Mon, 26 Sep 2011 03:05:35 +0200\r
+Message-Id:\r
+ <1316999137-28257-7-git-send-email-4winter@informatik.uni-hamburg.de>\r
+X-Mailer: git-send-email 1.7.6.3\r
+In-Reply-To:\r
+ <1316999137-28257-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+References:\r
+ <1316999137-28257-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+X-Mailman-Approved-At: Mon, 26 Sep 2011 09:17:56 -0700\r
+Cc: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 26 Sep 2011 01:06:42 -0000\r
+\r
+To make the exception handling more effective in code using the\r
+python bindings it is necessary to differentiate between the\r
+different kind of failures.\r
+\r
+Add an exception class for each status code and add a decode\r
+classmethod to the NotmuchError class that acts as a factory.\r
+\r
+Import the new classes in __init__.py so they can be easily\r
+imported by anyone.\r
+\r
+Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+---\r
+ bindings/python/notmuch/__init__.py | 16 ++++++++++++++-\r
+ bindings/python/notmuch/globals.py | 37 +++++++++++++++++++++++++++++++++++\r
+ 2 files changed, 52 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/bindings/python/notmuch/__init__.py b/bindings/python/notmuch/__init__.py\r
+index a7b558f..7e6a68c 100644\r
+--- a/bindings/python/notmuch/__init__.py\r
++++ b/bindings/python/notmuch/__init__.py\r
+@@ -56,7 +56,21 @@ from notmuch.database import Database, Query\r
+ from notmuch.message import Messages, Message\r
+ from notmuch.thread import Threads, Thread\r
+ from notmuch.tag import Tags\r
+-from notmuch.globals import nmlib, STATUS, NotmuchError\r
++from notmuch.globals import (\r
++ nmlib,\r
++ STATUS,\r
++ NotmuchError,\r
++ OutOfMemoryError,\r
++ ReadOnlyDatabaseError,\r
++ XapianError,\r
++ FileError,\r
++ FileNotEmailError,\r
++ DuplicateMessageIdError,\r
++ NullPointerError,\r
++ TagTooLongError,\r
++ UnbalancedFreezeThawError,\r
++ NotInitializedError\r
++)\r
+ from notmuch.version import __VERSION__\r
+ __LICENSE__ = "GPL v3+"\r
+ __AUTHOR__ = 'Sebastian Spaeth <Sebastian@SSpaeth.de>'\r
+diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py\r
+index 8b73f91..e454384 100644\r
+--- a/bindings/python/notmuch/globals.py\r
++++ b/bindings/python/notmuch/globals.py\r
+@@ -102,6 +102,43 @@ class NotmuchError(Exception):\r
+ else:\r
+ return 'Unknown error'\r
+ \r
++ @classmethod\r
++ def decode(cls, status, message=None):\r
++ assert 0 < status <= 10\r
++ return [\r
++ OutOfMemoryError,\r
++ ReadOnlyDatabaseError,\r
++ XapianError,\r
++ FileError,\r
++ FileNotEmailError,\r
++ DuplicateMessageIdError,\r
++ NullPointerError,\r
++ TagTooLongError,\r
++ UnbalancedFreezeThawError,\r
++ NotInitializedError\r
++ ][status - 1](message)\r
++\r
++class OutOfMemoryError(NotmuchError):\r
++ status = 1\r
++class ReadOnlyDatabaseError(NotmuchError):\r
++ status = 2\r
++class XapianError(NotmuchError):\r
++ status = 3\r
++class FileError(NotmuchError):\r
++ status = 4\r
++class FileNotEmailError(NotmuchError):\r
++ status = 5\r
++class DuplicateMessageIdError(NotmuchError):\r
++ status = 6\r
++class NullPointerError(NotmuchError):\r
++ status = 7\r
++class TagTooLongError(NotmuchError):\r
++ status = 8\r
++class UnbalancedFreezeThawError(NotmuchError):\r
++ status = 9\r
++class NotInitializedError(NotmuchError):\r
++ status = 10\r
++\r
+ def _str(value):\r
+ """Ensure a nicely utf-8 encoded string to pass to libnotmuch\r
+ \r
+-- \r
+1.7.6.3\r
+\r