lib: add new status code for query syntax errors.

This will help provide more meaningful error messages without special
casing on the client side.
This commit is contained in:
David Bremner 2021-08-24 08:17:15 -07:00
parent e3b1a0a6a5
commit 9ae4188610
4 changed files with 10 additions and 0 deletions

View file

@ -53,6 +53,7 @@ ffibuilder.cdef(
NOTMUCH_STATUS_NO_CONFIG,
NOTMUCH_STATUS_NO_DATABASE,
NOTMUCH_STATUS_DATABASE_EXISTS,
NOTMUCH_STATUS_BAD_QUERY_SYNTAX,
NOTMUCH_STATUS_LAST_STATUS
} notmuch_status_t;
typedef enum {

View file

@ -56,6 +56,8 @@ class NotmuchError(Exception):
NoDatabaseError,
capi.lib.NOTMUCH_STATUS_DATABASE_EXISTS:
DatabaseExistsError,
capi.lib.NOTMUCH_STATUS_BAD_QUERY_SYNTAX:
QuerySyntaxError,
}
return types[status]
@ -103,6 +105,7 @@ class IllegalArgumentError(NotmuchError): pass
class NoConfigError(NotmuchError): pass
class NoDatabaseError(NotmuchError): pass
class DatabaseExistsError(NotmuchError): pass
class QuerySyntaxError(NotmuchError): pass
class ObjectDestroyedError(NotmuchError):
"""The object has already been destroyed and it's memory freed.

View file

@ -309,6 +309,8 @@ notmuch_status_to_string (notmuch_status_t status)
return "No database found";
case NOTMUCH_STATUS_DATABASE_EXISTS:
return "Database exists, not recreated";
case NOTMUCH_STATUS_BAD_QUERY_SYNTAX:
return "Syntax error in query";
default:
case NOTMUCH_STATUS_LAST_STATUS:
return "Unknown error status value";

View file

@ -220,6 +220,10 @@ typedef enum _notmuch_status {
* Database exists, so not (re)-created
*/
NOTMUCH_STATUS_DATABASE_EXISTS,
/**
* Syntax error in query
*/
NOTMUCH_STATUS_BAD_QUERY_SYNTAX,
/**
* Not an actual status value. Just a way to find out how many
* valid status values there are.