summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
717279f)
If an earlier exception occurred, then it's not unexpected for the
flush to fail as well. So in that case, we'll silently catch the
exception. Otherwise, make some noise about things going wrong at the
time of flush.
#include <xapian.h>
struct _notmuch_database {
#include <xapian.h>
struct _notmuch_database {
+ notmuch_bool_t exception_reported;
char *path;
notmuch_database_mode_t mode;
Xapian::Database *xapian_db;
char *path;
notmuch_database_mode_t mode;
Xapian::Database *xapian_db;
}
notmuch = talloc (NULL, notmuch_database_t);
}
notmuch = talloc (NULL, notmuch_database_t);
+ notmuch->exception_reported = FALSE;
notmuch->path = talloc_strdup (notmuch, path);
if (notmuch->path[strlen (notmuch->path) - 1] == '/')
notmuch->path = talloc_strdup (notmuch, path);
if (notmuch->path[strlen (notmuch->path) - 1] == '/')
void
notmuch_database_close (notmuch_database_t *notmuch)
{
void
notmuch_database_close (notmuch_database_t *notmuch)
{
- if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
- (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush ();
+ try {
+ if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
+ (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush ();
+ } catch (const Xapian::Error &error) {
+ if (! notmuch->exception_reported) {
+ fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n",
+ error.get_msg().c_str());
+ }
+ }
delete notmuch->term_gen;
delete notmuch->query_parser;
delete notmuch->term_gen;
delete notmuch->query_parser;
} catch (const Xapian::Error &error) {
fprintf (stderr, "A Xapian exception occurred setting timestamp: %s.\n",
error.get_msg().c_str());
} catch (const Xapian::Error &error) {
fprintf (stderr, "A Xapian exception occurred setting timestamp: %s.\n",
error.get_msg().c_str());
+ notmuch->exception_reported = TRUE;
ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
}
ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
}
} catch (const Xapian::Error &error) {
fprintf (stderr, "A Xapian exception occurred adding message: %s.\n",
error.get_description().c_str());
} catch (const Xapian::Error &error) {
fprintf (stderr, "A Xapian exception occurred adding message: %s.\n",
error.get_description().c_str());
+ notmuch->exception_reported = TRUE;
ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
goto DONE;
}
ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
goto DONE;
}
} catch (const Xapian::Error &error) {
fprintf (stderr, "A Xapian exception occurred creating message: %s\n",
error.get_msg().c_str());
} catch (const Xapian::Error &error) {
fprintf (stderr, "A Xapian exception occurred creating message: %s\n",
error.get_msg().c_str());
+ notmuch->exception_reported = TRUE;
*status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
return NULL;
}
*status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
return NULL;
}
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);
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->exception_reported = TRUE;
}
return _notmuch_messages_create (message_list);
}
return _notmuch_messages_create (message_list);