--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 162AC431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 13 Jan 2014 13:15:26 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id pby0SulQ9jTb for <notmuch@notmuchmail.org>;\r
+ Mon, 13 Jan 2014 13:15:18 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 0540B431FAE\r
+ for <notmuch@notmuchmail.org>; Mon, 13 Jan 2014 13:15:18 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 8C86F100086;\r
+ Mon, 13 Jan 2014 23:15:13 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Tomi Valkeinen <tomi.valkeinen@iki.fi>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/2] lib: fix error handling\r
+In-Reply-To: <1384837831-9206-2-git-send-email-tomi.valkeinen@iki.fi>\r
+References: <1384837831-9206-1-git-send-email-tomi.valkeinen@iki.fi>\r
+ <1384837831-9206-2-git-send-email-tomi.valkeinen@iki.fi>\r
+User-Agent: Notmuch/0.17+34~g98b959f (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Mon, 13 Jan 2014 23:15:13 +0200\r
+Message-ID: <m2txd7lh26.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 13 Jan 2014 21:15:26 -0000\r
+\r
+On Tue, Nov 19 2013, Tomi Valkeinen <tomi.valkeinen@iki.fi> wrote:\r
+\r
+> Currently if a Xapian exception happens in notmuch_message_get_header,\r
+> the exception is not caught leading to crash. In\r
+> notmuch_message_get_date the exception is caught, but an internal error\r
+> is raised, again leading to crash.\r
+>\r
+> This patch fixes the error handling by making both functions catch the\r
+> Xapian exceptions, print an error and return NULL or 0.\r
+>\r
+> The 'notmuch->exception_reported' is also set, as is done elsewhere,\r
+> even if I don't really get the idea of that field.\r
+\r
+Althoug this adds the library fprintf() count by one this is important\r
+and consistent fix to the library...\r
+\r
+... whenever we get into consensus how to handle library logging it\r
+is not big deal to convert this also to the new call too.\r
+\r
++1\r
+\r
+Tomi\r
+\r
+\r
+>\r
+> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>\r
+> ---\r
+> lib/message.cc | 34 ++++++++++++++++++++++------------\r
+> 1 file changed, 22 insertions(+), 12 deletions(-)\r
+>\r
+> diff --git a/lib/message.cc b/lib/message.cc\r
+> index 1b46379..c91f3a5 100644\r
+> --- a/lib/message.cc\r
+> +++ b/lib/message.cc\r
+> @@ -412,19 +412,27 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message)\r
+> const char *\r
+> notmuch_message_get_header (notmuch_message_t *message, const char *header)\r
+> {\r
+> - std::string value;\r
+> + try {\r
+> + std::string value;\r
+> \r
+> - /* Fetch header from the appropriate xapian value field if\r
+> - * available */\r
+> - if (strcasecmp (header, "from") == 0)\r
+> - value = message->doc.get_value (NOTMUCH_VALUE_FROM);\r
+> - else if (strcasecmp (header, "subject") == 0)\r
+> - value = message->doc.get_value (NOTMUCH_VALUE_SUBJECT);\r
+> - else if (strcasecmp (header, "message-id") == 0)\r
+> - value = message->doc.get_value (NOTMUCH_VALUE_MESSAGE_ID);\r
+> + /* Fetch header from the appropriate xapian value field if\r
+> + * available */\r
+> + if (strcasecmp (header, "from") == 0)\r
+> + value = message->doc.get_value (NOTMUCH_VALUE_FROM);\r
+> + else if (strcasecmp (header, "subject") == 0)\r
+> + value = message->doc.get_value (NOTMUCH_VALUE_SUBJECT);\r
+> + else if (strcasecmp (header, "message-id") == 0)\r
+> + value = message->doc.get_value (NOTMUCH_VALUE_MESSAGE_ID);\r
+> \r
+> - if (!value.empty())\r
+> - return talloc_strdup (message, value.c_str ());\r
+> + if (!value.empty())\r
+> + return talloc_strdup (message, value.c_str ());\r
+> +\r
+> + } catch (Xapian::Error &error) {\r
+> + fprintf (stderr, "A Xapian exception occurred when reading header: %s\n",\r
+> + error.get_msg().c_str());\r
+> + message->notmuch->exception_reported = TRUE;\r
+> + return NULL;\r
+> + }\r
+> \r
+> /* Otherwise fall back to parsing the file */\r
+> _notmuch_message_ensure_message_file (message);\r
+> @@ -766,7 +774,9 @@ notmuch_message_get_date (notmuch_message_t *message)\r
+> try {\r
+> value = message->doc.get_value (NOTMUCH_VALUE_TIMESTAMP);\r
+> } catch (Xapian::Error &error) {\r
+> - INTERNAL_ERROR ("Failed to read timestamp value from document.");\r
+> + fprintf (stderr, "A Xapian exception occurred when reading date: %s\n",\r
+> + error.get_msg().c_str());\r
+> + message->notmuch->exception_reported = TRUE;\r
+> return 0;\r
+> }\r
+> \r
+> -- \r
+> 1.8.3.2\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r