From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id ENt7JV33A2FtgQEAgWs5BA (envelope-from ) for ; Fri, 30 Jul 2021 14:58:05 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id SNA5IV33A2FyJAAA1q6Kng (envelope-from ) for ; Fri, 30 Jul 2021 12:58:05 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4E78ED859 for ; Fri, 30 Jul 2021 14:58:05 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id D0BCC29237; Fri, 30 Jul 2021 08:57:00 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id D76FB291FE for ; Fri, 30 Jul 2021 08:56:29 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id CBFFE5FD17; Fri, 30 Jul 2021 08:56:29 -0400 (EDT) Received: (nullmailer pid 2166873 invoked by uid 1000); Fri, 30 Jul 2021 12:56:10 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 05/27] lib: add new status code for query syntax errors. Date: Fri, 30 Jul 2021 09:55:45 -0300 Message-Id: <20210730125607.2165433-6-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210730125607.2165433-1-david@tethera.net> References: <20210730125607.2165433-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: IAA6SIYY3DPMSCVZCPFFJQVCOLEQM65K X-Message-ID-Hash: IAA6SIYY3DPMSCVZCPFFJQVCOLEQM65K X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1627649885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=cSjvOMorHJaG6+799FFHwH35VvTCbq7uTSWAvcGRzQc=; b=Fdq0jqgj4N50LdzLDiQxbTWw5q4CYhVaWh4NwsEOgoiX0lOfgyVeMKaei2HY9sLEhuRAsS P7Qg+aWZ16UW89TFdJOQbYRHCd1j/JzRd1Wke/HVT6AAka/+NxQBztqx793od24HJvVfNW yMq4FHs1WbhpJk71vr5kW1HDgIOppB3VkyoTA3/jfsbGEQxrfAmHGw+5IbW1htOlziuwAC Hi/zbhohlyTW+iiS+o7GrHJtVduDsteKLjlF8hKy+GmUVLfy6gM9c26MxbMU0jJfF1ZUOx vpMTtIjZIIaV1tnDHhSNTfE7DC8pk8jMsACMAtDbi+sh4Ewb/KucN3GgqqEKOA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1627649885; a=rsa-sha256; cv=none; b=j1YTiUsJP595tg5Nt/x904QDy0zbzFJIM+HweAhjs8mCUexNzSr2zpoWIQhRR6xOUm1nZs W01YidBlWEerLD4SrZmj3FTCk9gaMQxmha3nS+x2qCcW9MWbKWaYdvYNLph/3ni4uuftxu 51aIzX2HGGfPKRSUq0gfEzoIM0AvUWvhQt/oyMbhHz/gicA01BLQtqRkMT1wKE7CSybHpA PLBPUrJrgOlVedrMqv8kQhdEfbYjq2eCQVQ+WEwWfGv1qsBWt1lKNeEpxsjOjd9/bZkgIP QqunEMQ6spNQlDW8jJ5r/XgL0M8hkEVOyoequIsTJXV6/UP3PE8zgE9h+F4POw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 0.52 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 4E78ED859 X-Spam-Score: 0.52 X-Migadu-Scanner: scn1.migadu.com X-TUID: rSLaiKwP6MIu This will help provide more meaningful error messages without special casing on the client side. --- bindings/python-cffi/notmuch2/_build.py | 1 + bindings/python-cffi/notmuch2/_errors.py | 3 +++ lib/database.cc | 2 ++ lib/notmuch.h | 4 ++++ 4 files changed, 10 insertions(+) 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 6f33c045..3f7ba132 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -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. -- 2.30.2