From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sL3aDPtVFWHRNwEAgWs5BA (envelope-from ) for ; Thu, 12 Aug 2021 19:10:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id mEieCPtVFWGicAAA1q6Kng (envelope-from ) for ; Thu, 12 Aug 2021 17:10:19 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (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 8898B6DF3 for ; Thu, 12 Aug 2021 19:10:18 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5FBC52922B; Thu, 12 Aug 2021 13:09:24 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id BF0BE2C01A for ; Thu, 12 Aug 2021 13:09:16 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id B86155FD5C; Thu, 12 Aug 2021 13:09:16 -0400 (EDT) Received: (nullmailer pid 1348730 invoked by uid 1000); Thu, 12 Aug 2021 17:07:43 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 05/31] lib: add new status code for query syntax errors. Date: Thu, 12 Aug 2021 10:07:02 -0700 Message-Id: <20210812170728.1348333-6-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210812170728.1348333-1-david@tethera.net> References: <20210812170728.1348333-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: IWVQADJ6C7WVOY65DR6PZTKE2NIVSCFZ X-Message-ID-Hash: IWVQADJ6C7WVOY65DR6PZTKE2NIVSCFZ 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=1628788218; 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=fO875HN5N30mgGpdUOxT1bGqcKCqGAIdjEDsGUhIS9vspOTr6WR6Z6Cj2ISapJeW//+Bsc Wn1Cps8M4IK2pl1d9uQn4tvwUf+B3yIzzZ4UmdwvgwrCqBbXXZ14Wro6sY8jKQsESP/t40 ZBeY9yjScpopcNGAWyEeodwOtUePpz4QaMWuvsAE8dul7417IrYBhFdVulX1RlTfC3hPbF bXQcX6qh21ux79WDHam1aqwuW7S5tYWjeTSwF8srLfm7O04ylDUf/awchSxGMFiMGI/iD4 30zilf7I+CaFy2iNIDfl99X/vVxdm7CeE+tMYvfph6t/PMNCLYSEDuni4Jxk3A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628788218; a=rsa-sha256; cv=none; b=dcjSRqJ5JyhQletTf71Ja1ROhUgDBSnkeTu3Q9bMkJ6SW+Tj3RXD7c09N4wLrLUAEtei0f cZ9eohAAGFCyZLZuc0mErvoX9/C6wEk/Js3bkN3wBexxV+S3ZDr5QfKenoveSImyjzzP1q hKSTDt3hD5q2Tkp0gakDipWcLblAa76x5QXQra89KAdJ6xcJlN6rnJUKkxa1XVOVMmA2Fk K9mvyu9blsBMqIL0HgMkMUhyF6vtC+uA6JgbxxMfSEejvp0cAfnNq6Q/NSP0Br87j8Odhp qVlOEgVxJwp6uYu1A4gAJ8Udke1VtYljqq2HaG4Twn/zvWa173JvQG6dtWfZYA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 0.48 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 8898B6DF3 X-Spam-Score: 0.48 X-Migadu-Scanner: scn0.migadu.com X-TUID: XWHV8k7LrHsQ 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