aboutsummaryrefslogtreecommitdiffhomepage
path: root/bindings
diff options
context:
space:
mode:
authorGravatar Peter Wang <novalazy@gmail.com>2014-04-16 22:59:18 +1000
committerGravatar David Bremner <david@tethera.net>2014-09-16 20:16:52 +0200
commitea90d8e043e348616d9e17cef66c17274342dacd (patch)
tree598574cb8c50f70a59419dfed4cdf6ed9732e507 /bindings
parent6754ad9f9e46a08da9332a066b2dc606c18277d0 (diff)
python: handle return status of database close and destroy
Throw an exception if notmuch_database_close or notmuch_database_destroy fail.
Diffstat (limited to 'bindings')
-rw-r--r--bindings/python/notmuch/database.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
index 7ddf5cfe..5b58e099 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -157,11 +157,13 @@ class Database(object):
_destroy = nmlib.notmuch_database_destroy
_destroy.argtypes = [NotmuchDatabaseP]
- _destroy.restype = None
+ _destroy.restype = c_uint
def __del__(self):
if self._db:
- self._destroy(self._db)
+ status = self._destroy(self._db)
+ if status != STATUS.SUCCESS:
+ raise NotmuchError(status)
def _assert_db_is_initialized(self):
"""Raises :exc:`NotInitializedError` if self._db is `None`"""
@@ -217,7 +219,7 @@ class Database(object):
_close = nmlib.notmuch_database_close
_close.argtypes = [NotmuchDatabaseP]
- _close.restype = None
+ _close.restype = c_uint
def close(self):
'''
@@ -231,7 +233,9 @@ class Database(object):
NotmuchError.
'''
if self._db:
- self._close(self._db)
+ status = self._close(self._db)
+ if status != STATUS.SUCCESS:
+ raise NotmuchError(status)
def __enter__(self):
'''