]> git.notmuchmail.org Git - notmuch/commitdiff
lib: handle xapian exception in n_m_remove_all_tags
authorDavid Bremner <david@tethera.net>
Thu, 9 Jul 2020 00:17:04 +0000 (21:17 -0300)
committerDavid Bremner <david@tethera.net>
Mon, 20 Jul 2020 11:54:42 +0000 (08:54 -0300)
At least the exception we already catch should be reported properly.

lib/message.cc
lib/notmuch.h
test/T560-lib-error.sh

index 8e090aa316a70fb2ce670f35c9f2c174b069cb56..09708ed9dcb6d12d7ac888cdde0c5f20d6d8369d 100644 (file)
@@ -2071,16 +2071,20 @@ notmuch_message_remove_all_tags (notmuch_message_t *message)
     status = _notmuch_database_ensure_writable (message->notmuch);
     if (status)
        return status;
     status = _notmuch_database_ensure_writable (message->notmuch);
     if (status)
        return status;
+    tags = notmuch_message_get_tags (message);
+    if (! tags)
+       return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
 
 
-    for (tags = notmuch_message_get_tags (message);
+    for (;
         notmuch_tags_valid (tags);
         notmuch_tags_move_to_next (tags)) {
        tag = notmuch_tags_get (tags);
 
        private_status = _notmuch_message_remove_term (message, "tag", tag);
        if (private_status) {
         notmuch_tags_valid (tags);
         notmuch_tags_move_to_next (tags)) {
        tag = notmuch_tags_get (tags);
 
        private_status = _notmuch_message_remove_term (message, "tag", tag);
        if (private_status) {
-           INTERNAL_ERROR ("_notmuch_message_remove_term return unexpected value: %d\n",
-                           private_status);
+           return COERCE_STATUS (private_status,
+                                  "_notmuch_message_remove_term return unexpected value: %d\n",
+                                  private_status);
        }
     }
 
        }
     }
 
index edad3d8a3d26a839f848a095158d3ab50c491c22..82d6c10fefc7496c55e56a0541e8305538db20ee 100644 (file)
@@ -1635,8 +1635,10 @@ notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
  * See notmuch_message_freeze for an example showing how to safely
  * replace tag values.
  *
  * See notmuch_message_freeze for an example showing how to safely
  * replace tag values.
  *
- * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
- *     mode so message cannot be modified.
+ * @retval #NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
+ *     read-only mode so message cannot be modified.
+ * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION: an execption was thrown
+ *      accessing the database.
  */
 notmuch_status_t
 notmuch_message_remove_all_tags (notmuch_message_t *message);
  */
 notmuch_status_t
 notmuch_message_remove_all_tags (notmuch_message_t *message);
index 52057c2515febb549062ead9a051d9d36dacc19d..5b5ad7651b074ef34e77ac28522e3432cba81352 100755 (executable)
@@ -583,7 +583,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Handle removing all tags with closed db"
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Handle removing all tags with closed db"
-test_subtest_known_broken
 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
     {
         notmuch_status_t status;
 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
     {
         notmuch_status_t status;