X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=message-file.c;h=cb2bf665006c4de4734f446e28c782c08a0f8a8a;hp=4f4f551be8e3051497640ab63ff75c4ec02d4f4a;hb=be9e3ee3132457ea5936bd1225294bdfe3949a4c;hpb=cd4a8734d3bb151df70d51a84903bff994439b05 diff --git a/message-file.c b/message-file.c index 4f4f551b..cb2bf665 100644 --- a/message-file.c +++ b/message-file.c @@ -125,10 +125,8 @@ notmuch_message_file_restrict_headersv (notmuch_message_file_t *message, { char *header; - if (message->parsing_started ) { - fprintf (stderr, "Error: notmuch_message_file_restrict_headers called after parsing has started\n"); - exit (1); - } + if (message->parsing_started) + INTERNAL_ERROR ("notmuch_message_file_restrict_headers called after parsing has started"); while (1) { header = va_arg (va_headers, char*); @@ -298,5 +296,17 @@ notmuch_message_file_get_header (notmuch_message_file_t *message, message->value.len = 0; } + /* We've parsed all headers and never found the one we're looking + * for. It's probably just not there, but let's check that we + * didn't make a mistake preventing us from seeing it. */ + if (message->restrict_headers && + ! g_hash_table_lookup_extended (message->headers, + header_desired, NULL, NULL)) + { + INTERNAL_ERROR ("Attempt to get header \"%s\" which was not\n" + "included in call to notmuch_message_file_restrict_headers\n", + header_desired); + } + return NULL; }