X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fquery.cc;h=f53215dbaf5902fca51d3c7dd5ac3628802ded00;hb=d4321162ae1bd5cbbf620a8bc26cec5430acf90b;hp=57aa6d24844d49ced318f0148f99163bcc932a2a;hpb=6d44e5ac4743f618513c9a080733d91afa683f16;p=notmuch diff --git a/lib/query.cc b/lib/query.cc index 57aa6d24..f53215db 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -296,9 +296,12 @@ notmuch_query_search_messages_st (notmuch_query_t *query, return NOTMUCH_STATUS_SUCCESS; } catch (const Xapian::Error &error) { - fprintf (stderr, "A Xapian exception occurred performing query: %s\n", - error.get_msg().c_str()); - fprintf (stderr, "Query string was: %s\n", query->query_string); + _notmuch_database_log (notmuch, + "A Xapian exception occurred performing query: %s\n" + "Query string was: %s\n", + error.get_msg().c_str(), + query->query_string); + notmuch->exception_reported = TRUE; talloc_free (messages); return NOTMUCH_STATUS_XAPIAN_EXCEPTION; @@ -597,9 +600,12 @@ notmuch_query_count_messages (notmuch_query_t *query) count = mset.get_matches_estimated(); } catch (const Xapian::Error &error) { - fprintf (stderr, "A Xapian exception occurred: %s\n", - error.get_msg().c_str()); - fprintf (stderr, "Query string was: %s\n", query->query_string); + _notmuch_database_log (notmuch, + "A Xapian exception occurred performing query: %s\n" + "Query string was: %s\n", + error.get_msg().c_str(), + query->query_string); + } return count; @@ -612,10 +618,14 @@ notmuch_query_count_threads (notmuch_query_t *query) GHashTable *hash; unsigned int count; notmuch_sort_t sort; + notmuch_status_t status; sort = query->sort; query->sort = NOTMUCH_SORT_UNSORTED; - messages = notmuch_query_search_messages (query); + status = notmuch_query_search_messages_st (query, &messages); + if (status) + return 0; + query->sort = sort; if (messages == NULL) return 0; @@ -648,3 +658,9 @@ notmuch_query_count_threads (notmuch_query_t *query) return count; } + +notmuch_database_t * +notmuch_query_get_database (notmuch_query_t *query) +{ + return query->notmuch; +}