From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sNSjGGwOJWGg4QAAgWs5BA (envelope-from ) for ; Tue, 24 Aug 2021 17:21:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 8J9MFGwOJWEiagAAB5/wlQ (envelope-from ) for ; Tue, 24 Aug 2021 15:21:16 +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 142D5848A for ; Tue, 24 Aug 2021 17:21:16 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 66A6F20548; Tue, 24 Aug 2021 11:20:41 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 15BEC20535 for ; Tue, 24 Aug 2021 11:20:30 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 0DCE45FD5C; Tue, 24 Aug 2021 11:20:29 -0400 (EDT) Received: (nullmailer pid 2942839 invoked by uid 1000); Tue, 24 Aug 2021 15:17:51 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 06/36] lib: add new status code for query syntax errors. Date: Tue, 24 Aug 2021 08:17:15 -0700 Message-Id: <20210824151745.2941868-7-david@tethera.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210824151745.2941868-1-david@tethera.net> References: <20210824151745.2941868-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: BELTF5H2OA45EJTKRA56N6C2WI7RVK67 X-Message-ID-Hash: BELTF5H2OA45EJTKRA56N6C2WI7RVK67 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=1629818476; 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=csiSL5tqF7zNE9fePTWDALF/NC/RvZaPwnHoJfHP5lg=; b=QBu4P2iQg4qXDIP0gBs8gFm2ciAcPZ6M9Ms4oeHR5gOqiiMlLUH7en4U9DNe4RCnEafc7Y LXom5ALz5ew3rRxBUqYnPRPlR6ctRzND59i/9SgwLf1nS6VzPsTsTdzTpm3PGcb5LL8A4a qI7zd2czVRjp2+HovZBeYhgpbNYSCGjsrQ/cl0vIsjg1ndJHoFcinyiS9+fVBM5NWKwLCW p9biLHUuJQ1PIxVk2Bv7iP8zIy++ZkZS2f6Iuda1HwkuQuMtxDMTcBFRJwmAfYoHskXuGi EUGguQ1kgMECV7y0e0DIA6gBRsOD4//t5riankmQdbYsbwPOYS2X0PaLZnnrsQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1629818476; a=rsa-sha256; cv=none; b=SP2TlL6HLAH/ypBYZu1ng3DTtDziHhcmbCbNjgVxdZB/smoUOXoC3uDu025n6m8KfduRWo VxaUGLAvT9fgRaZSFH5rHmSqcaMz4ecwUmMLsh6l6ma+wlAQIY73b3vg3siOdpP4h8Ffsf 4BNc9NHGcNtXjo+m1IPY61b5zJ44Z5SUS04LSKoHdUWwg+x3e70JB5nUgZtUNipqyJ86an O4vIXbpgQH7Y+Umcy2iTtQJgnOj/VQkwfRnD9WBv0776LX4/XgR+0gslV+rO2fiEH01DI5 W9mw4Le3orGEd16o3gLgmaNejO+pBJhnv/4WzJXErBNrV5vF+YSca54b2Daq6Q== 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.93 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: 142D5848A X-Spam-Score: -0.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: 4pWHUvtfPNW7 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 2f1ee951..546643e8 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.32.0