]> git.notmuchmail.org Git - notmuch/blobdiff - lib/message.cc
lib: catch exceptions in n_m_get_filenames
[notmuch] / lib / message.cc
index b7a64b1c3894c26224e78be165bf58ac445fa777..8e43a393c55171b425175537298c0ff0fecb6c3b 100644 (file)
@@ -572,9 +572,7 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header)
                return talloc_strdup (message, value.c_str ());
 
        } catch (Xapian::Error &error) {
-           _notmuch_database_log (notmuch_message_get_database (message), "A Xapian exception occurred when reading header: %s\n",
-                                  error.get_msg ().c_str ());
-           message->notmuch->exception_reported = true;
+           LOG_XAPIAN_EXCEPTION (message, error);
            return NULL;
        }
     }
@@ -604,7 +602,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);
@@ -1119,7 +1122,12 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message)
 const char *
 notmuch_message_get_filename (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 NULL;
+    }
 
     if (message->filename_list == NULL)
        return NULL;
@@ -1135,7 +1143,12 @@ notmuch_message_get_filename (notmuch_message_t *message)
 notmuch_filenames_t *
 notmuch_message_get_filenames (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 NULL;
+    }
 
     return _notmuch_filenames_create (message, message->filename_list);
 }