diff options
| author | David Bremner <david@tethera.net> | 2017-02-18 11:08:04 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2017-03-22 08:47:13 -0300 |
| commit | 242d5a3ed5ed85bb935c8ed4a4678d7596d8534d (patch) | |
| tree | 19dd13df847db2aa51a6b17eaef77264524d4002 /lib | |
| parent | 3721bd45d72e50436ee760b03ae533d49bbb8724 (diff) | |
lib: make notmuch_query_add_tag_exclude return a status value
Since this is an ABI breaking change, but we already bumped the SONAME
for the next release
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/notmuch.h | 19 | ||||
| -rw-r--r-- | lib/query.cc | 15 |
2 files changed, 21 insertions, 13 deletions
diff --git a/lib/notmuch.h b/lib/notmuch.h index e692e9bb..d374dc96 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -180,6 +180,11 @@ typedef enum _notmuch_status { */ NOTMUCH_STATUS_PATH_ERROR, /** + * The requested operation was ignored. Depending on the function, + * this may not be an actual error. + */ + NOTMUCH_STATUS_IGNORED, + /** * One of the arguments violates the preconditions for the * function, in a way not covered by a more specific argument. */ @@ -812,10 +817,20 @@ notmuch_query_get_sort (const notmuch_query_t *query); /** * Add a tag that will be excluded from the query results by default. - * This exclusion will be overridden if this tag appears explicitly in + * This exclusion will be ignored if this tag appears explicitly in * the query. + * + * @returns + * + * NOTMUCH_STATUS_SUCCESS: excluded was added successfully. + * + * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. + * Most likely a problem lazily parsing the query string. + * + * NOTMUCH_STATUS_IGNORED: tag is explicitely present in the query, so + * not excluded. */ -void +notmuch_status_t notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag); /** diff --git a/lib/query.cc b/lib/query.cc index b7d4d352..212e27f0 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -177,29 +177,22 @@ notmuch_query_get_sort (const notmuch_query_t *query) return query->sort; } -void +notmuch_status_t notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag) { notmuch_status_t status; char *term; status = _notmuch_query_ensure_parsed (query); - /* The following is not ideal error handling, but to avoid - * breaking the ABI, we can live with it for now. In particular at - * least in the notmuch CLI, any syntax error in the query is - * caught in a later call to _notmuch_query_ensure_parsed with a - * better error path. - * - * TODO: add status return to this function. - */ if (status) - return; + return status; term = talloc_asprintf (query, "%s%s", _find_prefix ("tag"), tag); if (query->terms.count(term) != 0) - return; /* XXX report ignoring exclude? */ + return NOTMUCH_STATUS_IGNORED; _notmuch_string_list_append (query->exclude_terms, term); + return NOTMUCH_STATUS_SUCCESS; } /* We end up having to call the destructors explicitly because we had |
