mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-28 21:54:10 +01:00
python: handle return status of database close and destroy
Throw an exception if notmuch_database_close or notmuch_database_destroy fail.
This commit is contained in:
parent
6754ad9f9e
commit
ea90d8e043
1 changed files with 8 additions and 4 deletions
|
@ -157,11 +157,13 @@ class Database(object):
|
||||||
|
|
||||||
_destroy = nmlib.notmuch_database_destroy
|
_destroy = nmlib.notmuch_database_destroy
|
||||||
_destroy.argtypes = [NotmuchDatabaseP]
|
_destroy.argtypes = [NotmuchDatabaseP]
|
||||||
_destroy.restype = None
|
_destroy.restype = c_uint
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if self._db:
|
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):
|
def _assert_db_is_initialized(self):
|
||||||
"""Raises :exc:`NotInitializedError` if self._db is `None`"""
|
"""Raises :exc:`NotInitializedError` if self._db is `None`"""
|
||||||
|
@ -217,7 +219,7 @@ class Database(object):
|
||||||
|
|
||||||
_close = nmlib.notmuch_database_close
|
_close = nmlib.notmuch_database_close
|
||||||
_close.argtypes = [NotmuchDatabaseP]
|
_close.argtypes = [NotmuchDatabaseP]
|
||||||
_close.restype = None
|
_close.restype = c_uint
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
'''
|
'''
|
||||||
|
@ -231,7 +233,9 @@ class Database(object):
|
||||||
NotmuchError.
|
NotmuchError.
|
||||||
'''
|
'''
|
||||||
if self._db:
|
if self._db:
|
||||||
self._close(self._db)
|
status = self._close(self._db)
|
||||||
|
if status != STATUS.SUCCESS:
|
||||||
|
raise NotmuchError(status)
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in a new issue