From: David Bremner Date: Tue, 30 Jun 2020 01:14:11 +0000 (-0300) Subject: lib/message: catch exception in n_m_get_thread_id X-Git-Tag: 0.31_rc0~165 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=dbdb860bb92b5eef0eadc6ffd1fd6d5bf64553b9 lib/message: catch exception in n_m_get_thread_id This allows us to return an error value from the library. --- 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;