This is to facilitate error handling, specifically retrieval of log messages from the notmuch database struct. --- lib/index.cc | 6 +++--- lib/message-property.cc | 4 ++-- lib/message.cc | 12 ++++++------ lib/notmuch-private.h | 2 -- lib/notmuch.h | 6 ++++++ 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/index.cc b/lib/index.cc index 8c145540..709b2ac4 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -314,7 +314,7 @@ _index_mime_part (notmuch_message_t *message, const char *charset; if (! part) { - _notmuch_database_log (_notmuch_message_database (message), + _notmuch_database_log (notmuch_message_get_database (message), "Warning: Not indexing empty mime part.\n"); return; } @@ -345,7 +345,7 @@ _index_mime_part (notmuch_message_t *message, if (i == 1) continue; if (i > 1) - _notmuch_database_log (_notmuch_message_database (message), + _notmuch_database_log (notmuch_message_get_database (message), "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n"); } if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) { @@ -369,7 +369,7 @@ _index_mime_part (notmuch_message_t *message, } if (! (GMIME_IS_PART (part))) { - _notmuch_database_log (_notmuch_message_database (message), + _notmuch_database_log (notmuch_message_get_database (message), "Warning: Not indexing unknown mime part: %s.\n", g_type_name (G_OBJECT_TYPE (part))); return; diff --git a/lib/message-property.cc b/lib/message-property.cc index e81843d3..54918be7 100644 --- a/lib/message-property.cc +++ b/lib/message-property.cc @@ -52,7 +52,7 @@ _notmuch_message_modify_property (notmuch_message_t *message, const char *key, c notmuch_status_t status; char *term = NULL; - status = _notmuch_database_ensure_writable (_notmuch_message_database (message)); + status = _notmuch_database_ensure_writable (notmuch_message_get_database (message)); if (status) return status; @@ -99,7 +99,7 @@ notmuch_message_remove_all_properties (notmuch_message_t *message, const char *k notmuch_status_t status; const char * term_prefix; - status = _notmuch_database_ensure_writable (_notmuch_message_database (message)); + status = _notmuch_database_ensure_writable (notmuch_message_get_database (message)); if (status) return status; diff --git a/lib/message.cc b/lib/message.cc index 9ba24e8c..fee8fc24 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -260,7 +260,7 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch, doc_id = _notmuch_database_generate_doc_id (notmuch); } catch (const Xapian::Error &error) { - _notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred creating message: %s\n", + _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred creating message: %s\n", error.get_msg().c_str()); notmuch->exception_reported = TRUE; *status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION; @@ -396,7 +396,7 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message) if (!message->in_reply_to) message->in_reply_to = talloc_strdup (message, ""); } catch (const Xapian::Error &error) { - _notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred fetching message metadata\n", + _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred fetching message metadata\n", error.get_msg().c_str()); message->notmuch->exception_reported = TRUE; return NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION; @@ -480,7 +480,7 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message) return; message->message_file = _notmuch_message_file_open_ctx ( - _notmuch_message_database (message), message, filename); + notmuch_message_get_database (message), message, filename); } const char * @@ -510,7 +510,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_database (message), "A Xapian exception occurred when reading header: %s\n", + _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; return NULL; @@ -976,7 +976,7 @@ notmuch_message_get_date (notmuch_message_t *message) try { value = message->doc.get_value (NOTMUCH_VALUE_TIMESTAMP); } catch (Xapian::Error &error) { - _notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred when reading date: %s\n", + _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred when reading date: %s\n", error.get_msg().c_str()); message->notmuch->exception_reported = TRUE; return 0; @@ -1818,7 +1818,7 @@ notmuch_message_destroy (notmuch_message_t *message) } notmuch_database_t * -_notmuch_message_database (notmuch_message_t *message) +notmuch_message_get_database (notmuch_message_t *message) { return message->notmuch; } diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 7b35fc5b..2cad0795 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -503,8 +503,6 @@ _notmuch_query_count_documents (notmuch_query_t *query, void _notmuch_message_add_reply (notmuch_message_t *message, notmuch_message_t *reply); -notmuch_database_t * -_notmuch_message_database (notmuch_message_t *message); /* sha1.c */ diff --git a/lib/notmuch.h b/lib/notmuch.h index 2e8ccb05..5fd85105 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -1662,6 +1662,12 @@ void notmuch_message_destroy (notmuch_message_t *message); /** + * Return the notmuch database of this message. + */ +notmuch_database_t * +notmuch_message_get_database (notmuch_message_t *message); + +/** * @name Message Properties * * This interface provides the ability to attach arbitrary (key,value) -- 2.11.0