unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/8] lib: propagate error return from some calls to _n_m_e_metadata
Date: Sat, 18 Feb 2017 10:45:46 -0400	[thread overview]
Message-ID: <20170218144551.22925-4-david@tethera.net> (raw)
In-Reply-To: <20170218144551.22925-1-david@tethera.net>

In this commit we take care of the easy cases, where _n_m_e_metadata
is called from a non-void function. Three tricker cases are left for
future commits.
---
 lib/message.cc | 15 +++++++++++----
 lib/notmuch.h  |  9 ++++-----
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index 916dd441..16ea980c 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -458,7 +458,9 @@ const char *
 notmuch_message_get_message_id (notmuch_message_t *message)
 {
     if (!message->message_id)
-	_notmuch_message_ensure_metadata (message);
+	if (_notmuch_message_ensure_metadata (message))
+	    return NULL;
+
     if (!message->message_id)
 	INTERNAL_ERROR ("Message with document ID of %u has no message ID.\n",
 			message->doc_id);
@@ -534,7 +536,9 @@ const char *
 _notmuch_message_get_in_reply_to (notmuch_message_t *message)
 {
     if (!message->in_reply_to)
-	_notmuch_message_ensure_metadata (message);
+	if (_notmuch_message_ensure_metadata (message))
+	    return NULL;
+
     return message->in_reply_to;
 }
 
@@ -542,7 +546,9 @@ const char *
 notmuch_message_get_thread_id (notmuch_message_t *message)
 {
     if (!message->thread_id)
-	_notmuch_message_ensure_metadata (message);
+	if (_notmuch_message_ensure_metadata (message))
+	    return NULL;
+
     if (!message->thread_id)
 	INTERNAL_ERROR ("Message with document ID of %u has no thread ID.\n",
 			message->doc_id);
@@ -982,7 +988,8 @@ notmuch_message_get_tags (notmuch_message_t *message)
     notmuch_tags_t *tags;
 
     if (!message->tag_list)
-	_notmuch_message_ensure_metadata (message);
+	if (_notmuch_message_ensure_metadata (message))
+	    return NULL;
 
     tags = _notmuch_tags_create (message, message->tag_list);
     /* _notmuch_tags_create steals the reference to the tag_list, but
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 16da8be9..62866e5a 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1286,9 +1286,7 @@ notmuch_messages_collect_tags (notmuch_messages_t *messages);
  * message is valid, (which is until the query from which it derived
  * is destroyed).
  *
- * This function will not return NULL since Notmuch ensures that every
- * message has a unique message ID, (Notmuch will generate an ID for a
- * message if the original file does not contain one).
+ * The function returns NULL on error.
  */
 const char *
 notmuch_message_get_message_id (notmuch_message_t *message);
@@ -1302,8 +1300,7 @@ notmuch_message_get_message_id (notmuch_message_t *message);
  * notmuch_message_destroy on 'message' or until a query from which it
  * derived is destroyed).
  *
- * This function will not return NULL since Notmuch ensures that every
- * message belongs to a single thread.
+ * The function returns NULL on error.
  */
 const char *
 notmuch_message_get_thread_id (notmuch_message_t *message);
@@ -1449,6 +1446,8 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header);
  * notmuch_tags_t object. (For consistency, we do provide a
  * notmuch_tags_destroy function, but there's no good reason to call
  * it if the message is about to be destroyed).
+ *
+ * The function returns NULL on error.
  */
 notmuch_tags_t *
 notmuch_message_get_tags (notmuch_message_t *message);
-- 
2.11.0

  parent reply	other threads:[~2017-02-18 14:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-18 14:45 add status value to _notmuch_message_ensure_metadata David Bremner
2017-02-18 14:45 ` [PATCH 1/8] lib: make _notmuch_message_ensure_metadata static David Bremner
2017-02-23 12:59   ` David Bremner
2017-02-18 14:45 ` [PATCH 2/8] lib: add status return to _notmuch_message_ensure_metadata David Bremner
2017-02-18 14:45 ` David Bremner [this message]
2017-02-18 14:45 ` [PATCH 4/8] lib: push error from nme_metadata through nme_filename_list David Bremner
2017-02-18 14:45 ` [PATCH 5/8] lib: make _notmuch_message_ensure_property_map static David Bremner
2017-02-18 14:45 ` [PATCH 6/8] lib: propagate errors from nme_metadata through properties API David Bremner
2017-02-18 14:45 ` [PATCH 7/8] lib: add notmuch_message_get_database to public API David Bremner
2017-02-18 14:45 ` [PATCH 8/8] lib: add status return to notmuch_message_get_flag David Bremner
2017-02-20  9:27 ` add status value to _notmuch_message_ensure_metadata Gaute Hope
2017-02-20  9:44   ` Gaute Hope
2017-02-23  0:58     ` David Bremner
2017-02-23  7:46       ` Gaute Hope
2017-02-23 11:59         ` David Bremner
2017-02-24  2:00           ` [RFC patch 1/2] lib: add notmuch_database_reopen David Bremner
2017-02-24  2:00             ` [RFC patch 2/2] lib: handle DatabaseModifiedError in _n_message_ensure_metadata David Bremner
2017-02-24  2:49               ` David Bremner
2017-02-24 10:21                 ` Gaute Hope
2017-02-24 11:40                   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170218144551.22925-4-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).