aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2020-07-05 10:00:21 -0300
committerDavid Bremner <david@tethera.net>2020-07-14 07:31:37 -0300
commit96befd0dd075c5d3a63902d72eff7fc1928ba541 (patch)
treef0d76277982e611759b01100eac9bc0c830f3a52
parent6dc62d8bea7ce537ba30e7f68061a27f03e0bda7 (diff)
lib: catch Xapian exceptions in n_m_count_files
This will require some care for the caller to check the sign, and not just add error returns into a running total.
-rw-r--r--lib/message.cc7
-rw-r--r--lib/notmuch.h3
-rwxr-xr-xtest/T560-lib-error.sh1
3 files changed, 8 insertions, 3 deletions
diff --git a/lib/message.cc b/lib/message.cc
index 364cdc9d..7713050a 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1156,7 +1156,12 @@ notmuch_message_get_filenames (notmuch_message_t *message)
int
notmuch_message_count_files (notmuch_message_t *message)
{
- _notmuch_message_ensure_filename_list (message);
+ try {
+ _notmuch_message_ensure_filename_list (message);
+ } catch (Xapian::Error &error) {
+ LOG_XAPIAN_EXCEPTION (message, error);
+ return -1;
+ }
return _notmuch_string_list_length (message->filename_list);
}
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 50d804fa..693e5076 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1412,7 +1412,8 @@ notmuch_message_get_replies (notmuch_message_t *message);
/**
* Get the total number of files associated with a message.
- * @returns Non-negative integer
+ * @returns Non-negative integer for file count.
+ * @returns Negative integer for error.
* @since libnotmuch 5.0 (notmuch 0.25)
*/
int
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index e1843d91..1635d0e7 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -487,7 +487,6 @@ EOF
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle counting files from closed database"
-test_subtest_known_broken
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
{
int result;