aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-08-24 08:17:15 -0700
committerDavid Bremner <david@tethera.net>2021-09-04 17:07:19 -0700
commit9ae4188610dc21101fe9bdeb158854fc7c63463e (patch)
tree128ce04297f525995feb10867e53c80a50fa768f
parente3b1a0a6a59691f6be9fd0cb3b0d01bb9a7fe2b7 (diff)
lib: add new status code for query syntax errors.
This will help provide more meaningful error messages without special casing on the client side.
-rw-r--r--bindings/python-cffi/notmuch2/_build.py1
-rw-r--r--bindings/python-cffi/notmuch2/_errors.py3
-rw-r--r--lib/database.cc2
-rw-r--r--lib/notmuch.h4
4 files changed, 10 insertions, 0 deletions
diff --git a/bindings/python-cffi/notmuch2/_build.py b/bindings/python-cffi/notmuch2/_build.py
index f712b6c5..24df939e 100644
--- a/bindings/python-cffi/notmuch2/_build.py
+++ b/bindings/python-cffi/notmuch2/_build.py
@@ -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 {
diff --git a/bindings/python-cffi/notmuch2/_errors.py b/bindings/python-cffi/notmuch2/_errors.py
index 9301073e..f55cc96b 100644
--- a/bindings/python-cffi/notmuch2/_errors.py
+++ b/bindings/python-cffi/notmuch2/_errors.py
@@ -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.
diff --git a/lib/database.cc b/lib/database.cc
index 31794900..7eb0de79 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -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";
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 2f1ee951..546643e8 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -221,6 +221,10 @@ typedef enum _notmuch_status {
*/
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.
*/