aboutsummaryrefslogtreecommitdiff
path: root/bindings/python
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-12-24 12:51:30 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2016-01-08 13:58:33 +0100
commit9ed1eea8b63115343ec4a32907d9a1e1b9c0b7f1 (patch)
tree74812d265e5cc417ccf55e1e69fcd2909f3c3598 /bindings/python
parente3d34ef0afba28a6e9dcab0057de90f688f4ca57 (diff)
python: add new errors
Add support for the new notmuch status codes UNSUPPORTED_OPERATION, UPGRADE_REQUIRED, and PATH_ERROR. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Diffstat (limited to 'bindings/python')
-rw-r--r--bindings/python/docs/source/status_and_errors.rst6
-rw-r--r--bindings/python/notmuch/__init__.py3
-rw-r--r--bindings/python/notmuch/errors.py21
3 files changed, 30 insertions, 0 deletions
diff --git a/bindings/python/docs/source/status_and_errors.rst b/bindings/python/docs/source/status_and_errors.rst
index dd6e31f8..68913f16 100644
--- a/bindings/python/docs/source/status_and_errors.rst
+++ b/bindings/python/docs/source/status_and_errors.rst
@@ -47,5 +47,11 @@ The following exceptions are all directly derived from NotmuchError. Each of the
:members:
.. autoexception:: UnbalancedAtomicError(message=None)
:members:
+.. autoexception:: UnsupportedOperationError(message=None)
+ :members:
+.. autoexception:: UpgradeRequiredError(message=None)
+ :members:
+.. autoexception:: PathError(message=None)
+ :members:
.. autoexception:: NotInitializedError(message=None)
:members:
diff --git a/bindings/python/notmuch/__init__.py b/bindings/python/notmuch/__init__.py
index 5561624e..29416a5b 100644
--- a/bindings/python/notmuch/__init__.py
+++ b/bindings/python/notmuch/__init__.py
@@ -75,6 +75,9 @@ from .errors import (
UnbalancedFreezeThawError,
UnbalancedAtomicError,
NotInitializedError,
+ UnsupportedOperationError,
+ UpgradeRequiredError,
+ PathError,
)
from .version import __VERSION__
__LICENSE__ = "GPL v3+"
diff --git a/bindings/python/notmuch/errors.py b/bindings/python/notmuch/errors.py
index f153a9c5..abca51d7 100644
--- a/bindings/python/notmuch/errors.py
+++ b/bindings/python/notmuch/errors.py
@@ -56,6 +56,9 @@ STATUS = Status(['SUCCESS',
'TAG_TOO_LONG',
'UNBALANCED_FREEZE_THAW',
'UNBALANCED_ATOMIC',
+ 'UNSUPPORTED_OPERATION',
+ 'UPGRADE_REQUIRED',
+ 'PATH_ERROR',
'NOT_INITIALIZED'])
"""STATUS is a class, whose attributes provide constants that serve as return
indicators for notmuch functions. Currently the following ones are defined. For
@@ -73,6 +76,9 @@ description.
* TAG_TOO_LONG
* UNBALANCED_FREEZE_THAW
* UNBALANCED_ATOMIC
+ * UNSUPPORTED_OPERATION
+ * UPGRADE_REQUIRED
+ * PATH_ERROR
* NOT_INITIALIZED
Invoke the class method `notmuch.STATUS.status2str` with a status value as
@@ -101,6 +107,9 @@ class NotmuchError(Exception, Python3StringMixIn):
STATUS.TAG_TOO_LONG: TagTooLongError,
STATUS.UNBALANCED_FREEZE_THAW: UnbalancedFreezeThawError,
STATUS.UNBALANCED_ATOMIC: UnbalancedAtomicError,
+ STATUS.UNSUPPORTED_OPERATION: UnsupportedOperationError,
+ STATUS.UPGRADE_REQUIRED: UpgradeRequiredError,
+ STATUS.PATH_ERROR: PathError,
STATUS.NOT_INITIALIZED: NotInitializedError,
}
assert 0 < status <= len(subclasses)
@@ -175,6 +184,18 @@ class UnbalancedAtomicError(NotmuchError):
status = STATUS.UNBALANCED_ATOMIC
+class UnsupportedOperationError(NotmuchError):
+ status = STATUS.UNSUPPORTED_OPERATION
+
+
+class UpgradeRequiredError(NotmuchError):
+ status = STATUS.UPGRADE_REQUIRED
+
+
+class PathError(NotmuchError):
+ status = STATUS.PATH_ERROR
+
+
class NotInitializedError(NotmuchError):
"""Derived from NotmuchError, this occurs if the underlying data
structure (e.g. database is not initialized (yet) or an iterator has