unofficial mirror of notmuch@notmuchmail.org
 help / color / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 4/4] lib/message: catch exception in n_m_get_thread_id
Date: Mon, 29 Jun 2020 22:14:11 -0300
Message-ID: <20200630011411.612552-5-david@tethera.net> (raw)
In-Reply-To: <20200630011411.612552-1-david@tethera.net>

This allows us to return an error value from the library.
---
 lib/message.cc         | 7 ++++++-
 test/T560-lib-error.sh | 1 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index b7a64b1c..3ca7b902 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -604,7 +604,12 @@ _notmuch_message_get_in_reply_to (notmuch_message_t *message)
 const char *
 notmuch_message_get_thread_id (notmuch_message_t *message)
 {
-    _notmuch_message_ensure_metadata (message, message->thread_id);
+    try {
+	_notmuch_message_ensure_metadata (message, message->thread_id);
+    } catch (Xapian::Error &error) {
+	LOG_XAPIAN_EXCEPTION (message, error);
+	return NULL;
+    }
     if (! message->thread_id)
 	INTERNAL_ERROR ("Message with document ID of %u has no thread ID.\n",
 			message->doc_id);
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index b5600851..81500536 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -360,7 +360,6 @@ test_expect_equal_file EXPECTED OUTPUT
 
 backup_database
 test_begin_subtest "Handle getting thread-id from closed database"
-test_subtest_known_broken
 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
     {
         const char *id2;
-- 
2.27.0

  parent reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30  1:14 introduce exception handling at top level of libnotmuch David Bremner
2020-06-30  1:14 ` [PATCH 1/4] test: add known broken test for error handling on closed database David Bremner
2020-06-30  1:14 ` [PATCH 2/4] lib: catch error from closed db in n_m_get_message_id David Bremner
2020-07-04 15:44   ` Floris Bruynooghe
2020-07-04 17:17     ` David Bremner
2020-07-05 11:17       ` David Bremner
2020-06-30  1:14 ` [PATCH 3/4] test: add known broken test for n_m_get_thread_id on closed db David Bremner
2020-06-30  1:14 ` David Bremner [this message]
2020-07-02 19:16 ` introduce exception handling at top level of libnotmuch Daniel Kahn Gillmor
2020-07-04  0:15   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200630011411.612552-5-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

unofficial mirror of notmuch@notmuchmail.org

Archives are clonable:
	git clone --mirror https://yhetil.org/notmuch/0 notmuch/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 notmuch notmuch/ https://yhetil.org/notmuch \
		notmuch@notmuchmail.org
	public-inbox-index notmuch

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.mail.notmuch.general
	nntp://news.gmane.io/gmane.mail.notmuch.general


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git