_notmuch_database_log (notmuch, "A Xapian exception occurred adding message: %s.\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
- ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ ret = _notmuch_xapian_error ();
goto DONE;
}
try {
notmuch->writable_xapian_db->set_metadata (CONFIG_PREFIX + key, value);
} catch (const Xapian::Error &error) {
- status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ status = _notmuch_xapian_error ();
notmuch->exception_reported = true;
_notmuch_database_log (notmuch, "Error: A Xapian exception occurred setting metadata: %s\n",
error.get_msg ().c_str ());
try {
value = notmuch->xapian_db->get_metadata (CONFIG_PREFIX + key);
} catch (const Xapian::Error &error) {
- status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ status = _notmuch_xapian_error ();
notmuch->exception_reported = true;
_notmuch_database_log (notmuch, "Error: A Xapian exception occurred getting metadata: %s\n",
error.get_msg ().c_str ());
"A Xapian exception occurred getting metadata iterator: %s.\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
- status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ status = _notmuch_xapian_error ();
}
*out = list;
error.get_msg ().c_str ());
notmuch->exception_reported = true;
*message_ret = NULL;
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
}
* transaction, ALL pending changes will be discarded */
notmuch->xapian_db->close ();
} catch (const Xapian::Error &error) {
- status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ status = _notmuch_xapian_error ();
if (! notmuch->exception_reported) {
_notmuch_database_log (notmuch,
"Error: A Xapian exception occurred closing database: %s\n",
compactor);
} catch (const Xapian::Error &error) {
_notmuch_database_log (notmuch, "Error while compacting: %s\n", error.get_msg ().c_str ());
- ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ ret = _notmuch_xapian_error ();
goto DONE;
}
_notmuch_database_log (notmuch, "A Xapian exception occurred beginning transaction: %s.\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
DONE:
_notmuch_database_log (notmuch, "A Xapian exception occurred committing transaction: %s.\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
if (notmuch->atomic_dirty) {
_notmuch_database_log (notmuch, "A Xapian exception occurred getting directory: %s.\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
- status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ status = _notmuch_xapian_error ();
}
return status;
}
"Error: A Xapian exception occurred finding message by filename: %s\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
- status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ status = _notmuch_xapian_error ();
}
DONE:
notmuch->exception_reported = true;
notmuch_directory_destroy (directory);
directory = NULL;
- *status_ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ *status_ret = _notmuch_xapian_error ();
}
DONE:
"A Xapian exception occurred setting directory mtime: %s.\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
return NOTMUCH_STATUS_SUCCESS;
"A Xapian exception occurred deleting directory entry: %s.\n",
error.get_msg ().c_str ());
directory->notmuch->exception_reported = true;
- status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ status = _notmuch_xapian_error ();
}
notmuch_directory_destroy (directory);
private_status = _notmuch_message_add_term (message, "property", term);
} catch (Xapian::Error &error) {
LOG_XAPIAN_EXCEPTION (message, error);
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
if (private_status)
_notmuch_message_remove_terms (message, term_prefix);
} catch (Xapian::Error &error) {
LOG_XAPIAN_EXCEPTION (message, error);
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
if (! _notmuch_message_frozen (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;
+ *status_ret = _notmuch_xapian_error_private ();
return NULL;
}
_notmuch_message_ensure_metadata (message, NULL);
} catch (Xapian::Error &error) {
LOG_XAPIAN_EXCEPTION (message, error);
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
*is_set = NOTMUCH_TEST_BIT (message->flags, flag);
}
} catch (Xapian::Error &error) {
LOG_XAPIAN_EXCEPTION (message, error);
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
if (count > 0) {
/* reintroduce a ghost in its place because there are still
}
} catch (Xapian::Error &error) {
LOG_XAPIAN_EXCEPTION (message, error);
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
}
_notmuch_message_invalidate_metadata (message, prefix_name);
} catch (Xapian::Error &error) {
LOG_XAPIAN_EXCEPTION (message, error);
- status = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
+ status = _notmuch_xapian_error_private ();
}
DONE:
! strcmp ((*i).c_str (), term))
out = true;
} catch (Xapian::Error &error) {
- status = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
+ status = _notmuch_xapian_error_private ();
}
talloc_free (term);
} catch (Xapian::Error &error) {
LOG_XAPIAN_EXCEPTION (message, error);
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
return NOTMUCH_STATUS_SUCCESS;
_notmuch_message_sync (message);
} catch (Xapian::Error &error) {
LOG_XAPIAN_EXCEPTION (message, error);
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
return NOTMUCH_STATUS_SUCCESS;
NOTMUCH_END_DECLS
#ifdef __cplusplus
+
+#include <xapian.h>
+
/* Implicit typecast from 'void *' to 'T *' is okay in C, but not in
* C++. In talloc_steal, an explicit cast is provided for type safety
* in some GCC versions. Otherwise, a cast is required. Provide a
#else
#define NODISCARD /**/
#endif
+
+/* Should be called from a Xapian::Error exception handler to map it
+ * into a notmuch status code. */
+static inline notmuch_private_status_t
+_notmuch_xapian_error_private (void)
+{
+ try {
+ throw;
+ } catch (const Xapian::DatabaseModifiedError& _e) {
+ return NOTMUCH_PRIVATE_STATUS_OPERATION_INVALIDATED;
+ } catch (const Xapian::Error& _e) {
+ return NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
+ }
+}
+
+static inline notmuch_status_t
+_notmuch_xapian_error (void)
+{
+ return COERCE_STATUS (_notmuch_xapian_error_private (),
+ "mapping Xapian exception");
+}
#endif
#endif
"Query string was: %s\n",
sx->val);
notmuch->exception_reported = true;
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
}
return NOTMUCH_STATUS_SUCCESS;
}
msg = error.get_msg ();
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
return NOTMUCH_STATUS_SUCCESS;
}
notmuch->exception_reported = true;
talloc_free (messages);
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
}
_notmuch_database_log_append (notmuch,
"Query string was: %s\n",
query->query_string);
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
*count_out = count;
"A Xapian exception occurred expanding query: %s\n",
error.get_msg ().c_str ());
msg = error.get_msg ();
- return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ return _notmuch_xapian_error ();
}
return NOTMUCH_STATUS_SUCCESS;