]> git.notmuchmail.org Git - notmuch/blobdiff - query.cc
add_message: Propagate error status from notmuch_message_create_for_message_id
[notmuch] / query.cc
index c68bd37ad7fdb4bab5cc6f35cffcda8792b70919..f5ee7aadc5ee7185037fce302c805ba1592c1f86 100644 (file)
--- a/query.cc
+++ b/query.cc
@@ -165,12 +165,24 @@ notmuch_results_has_more (notmuch_results_t *results)
 notmuch_message_t *
 notmuch_results_get (notmuch_results_t *results)
 {
+    notmuch_message_t *message;
     Xapian::docid doc_id;
+    notmuch_private_status_t status;
 
     doc_id = *results->iterator;
 
-    return _notmuch_message_create (results,
-                                   results->notmuch, doc_id);
+    message = _notmuch_message_create (results,
+                                      results->notmuch, doc_id,
+                                      &status);
+
+    if (message == NULL &&
+       status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND)
+    {
+       fprintf (stderr, "Internal error: a results iterator contains a non-existent document ID.\n");
+       exit (1);
+    }
+
+    return message;
 }
 
 void