notmuch show: Detect an internal error if a thread has no messages.
authorCarl Worth <cworth@cworth.org>
Wed, 18 Nov 2009 01:53:54 +0000 (17:53 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 18 Nov 2009 01:55:45 +0000 (17:55 -0800)
This really should be impossible---if there are no messages, then what
was the thread object created from? During recent debugging, it was
useful to have this error detected and reported.

notmuch-show.c

index 7749dbc4b68ffde96b39fe81c95a993a8e708955..a3f354edb6816c0b1b41038759a795b8da626db0 100644 (file)
@@ -211,6 +211,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
 
        messages = notmuch_thread_get_toplevel_messages (thread);
 
+       if (messages == NULL)
+           INTERNAL_ERROR ("Thread %s has no toplevel messages.\n",
+                           notmuch_thread_get_thread_id (thread));
+
        show_messages (ctx, messages, 0);
 
        notmuch_thread_destroy (thread);