Python bindings and Xapian exceptions

Matt mattator at gmail.com
Mon Dec 15 12:46:40 PST 2014


2014-12-15 21:41 GMT+01:00 David Bremner <david at tethera.net>:
> Matt <mattator at gmail.com> writes:
>
>>> > But for exceptions in general, yes the notmuch library does need to be
>>> > fixed to allow the caller of functions to distinguish between things
>>> > like "no matches found" and "an exception occurred, so it's unknown if
>>> > any messages match the search". That's a general class of library
>>> > interface bugs that all need to be fixed.
>>
>> I 've also hit this *API bug* and was wondering if a fix had been done since
>> then (I use notmuch 0.17) ? I found nothing on http://notmuchmail.org/news/
>
> Can you be more specific? I'd say in general no thorough overhaul of
> error handling has happened, but if you can tell us what particular
> libnotmuch function (or the equivalient python binding) you are having
> trouble with, we may be able to give a more informative answer.
>

For instance when using the python bindings:
In constructor I do
self.db = notmuch.Database(self.db_path)
and there I have a method called periodically that returns:
returns notmuch.Query(self.db, "tag:unread and tag:inbox").count_messages()

When it fails the previous method returns 0 and displays on stdout/stderr;
"A Xapian exception occurred: The revision being read has been
discarded - you should call Xapian::Database::reopen() and retry the
operation
Query string was: tag:unread and tag:inbox"

The way for me to detect an error is to redirect stdout and check if
the method outputted to stdout, which is not practical. I wish it
would either return "-1", throw an exception or return 2 numbers like
"errorcode, returned value". I personnally don't care if it's done at
the library level or in the python bindings.

Regards


More information about the notmuch mailing list