mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
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>
This commit is contained in:
parent
e3d34ef0af
commit
9ed1eea8b6
3 changed files with 30 additions and 0 deletions
|
@ -47,5 +47,11 @@ The following exceptions are all directly derived from NotmuchError. Each of the
|
||||||
:members:
|
:members:
|
||||||
.. autoexception:: UnbalancedAtomicError(message=None)
|
.. autoexception:: UnbalancedAtomicError(message=None)
|
||||||
:members:
|
:members:
|
||||||
|
.. autoexception:: UnsupportedOperationError(message=None)
|
||||||
|
:members:
|
||||||
|
.. autoexception:: UpgradeRequiredError(message=None)
|
||||||
|
:members:
|
||||||
|
.. autoexception:: PathError(message=None)
|
||||||
|
:members:
|
||||||
.. autoexception:: NotInitializedError(message=None)
|
.. autoexception:: NotInitializedError(message=None)
|
||||||
:members:
|
:members:
|
||||||
|
|
|
@ -75,6 +75,9 @@ from .errors import (
|
||||||
UnbalancedFreezeThawError,
|
UnbalancedFreezeThawError,
|
||||||
UnbalancedAtomicError,
|
UnbalancedAtomicError,
|
||||||
NotInitializedError,
|
NotInitializedError,
|
||||||
|
UnsupportedOperationError,
|
||||||
|
UpgradeRequiredError,
|
||||||
|
PathError,
|
||||||
)
|
)
|
||||||
from .version import __VERSION__
|
from .version import __VERSION__
|
||||||
__LICENSE__ = "GPL v3+"
|
__LICENSE__ = "GPL v3+"
|
||||||
|
|
|
@ -56,6 +56,9 @@ STATUS = Status(['SUCCESS',
|
||||||
'TAG_TOO_LONG',
|
'TAG_TOO_LONG',
|
||||||
'UNBALANCED_FREEZE_THAW',
|
'UNBALANCED_FREEZE_THAW',
|
||||||
'UNBALANCED_ATOMIC',
|
'UNBALANCED_ATOMIC',
|
||||||
|
'UNSUPPORTED_OPERATION',
|
||||||
|
'UPGRADE_REQUIRED',
|
||||||
|
'PATH_ERROR',
|
||||||
'NOT_INITIALIZED'])
|
'NOT_INITIALIZED'])
|
||||||
"""STATUS is a class, whose attributes provide constants that serve as return
|
"""STATUS is a class, whose attributes provide constants that serve as return
|
||||||
indicators for notmuch functions. Currently the following ones are defined. For
|
indicators for notmuch functions. Currently the following ones are defined. For
|
||||||
|
@ -73,6 +76,9 @@ description.
|
||||||
* TAG_TOO_LONG
|
* TAG_TOO_LONG
|
||||||
* UNBALANCED_FREEZE_THAW
|
* UNBALANCED_FREEZE_THAW
|
||||||
* UNBALANCED_ATOMIC
|
* UNBALANCED_ATOMIC
|
||||||
|
* UNSUPPORTED_OPERATION
|
||||||
|
* UPGRADE_REQUIRED
|
||||||
|
* PATH_ERROR
|
||||||
* NOT_INITIALIZED
|
* NOT_INITIALIZED
|
||||||
|
|
||||||
Invoke the class method `notmuch.STATUS.status2str` with a status value as
|
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.TAG_TOO_LONG: TagTooLongError,
|
||||||
STATUS.UNBALANCED_FREEZE_THAW: UnbalancedFreezeThawError,
|
STATUS.UNBALANCED_FREEZE_THAW: UnbalancedFreezeThawError,
|
||||||
STATUS.UNBALANCED_ATOMIC: UnbalancedAtomicError,
|
STATUS.UNBALANCED_ATOMIC: UnbalancedAtomicError,
|
||||||
|
STATUS.UNSUPPORTED_OPERATION: UnsupportedOperationError,
|
||||||
|
STATUS.UPGRADE_REQUIRED: UpgradeRequiredError,
|
||||||
|
STATUS.PATH_ERROR: PathError,
|
||||||
STATUS.NOT_INITIALIZED: NotInitializedError,
|
STATUS.NOT_INITIALIZED: NotInitializedError,
|
||||||
}
|
}
|
||||||
assert 0 < status <= len(subclasses)
|
assert 0 < status <= len(subclasses)
|
||||||
|
@ -175,6 +184,18 @@ class UnbalancedAtomicError(NotmuchError):
|
||||||
status = STATUS.UNBALANCED_ATOMIC
|
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):
|
class NotInitializedError(NotmuchError):
|
||||||
"""Derived from NotmuchError, this occurs if the underlying data
|
"""Derived from NotmuchError, this occurs if the underlying data
|
||||||
structure (e.g. database is not initialized (yet) or an iterator has
|
structure (e.g. database is not initialized (yet) or an iterator has
|
||||||
|
|
Loading…
Reference in a new issue