aboutsummaryrefslogtreecommitdiffhomepage
path: root/database.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-10-21 16:12:53 -0700
committerGravatar Carl Worth <cworth@cworth.org>2009-10-21 16:12:53 -0700
commit302d54834d090d7e62377883f36dc709c95e5673 (patch)
tree4349f104408f0963ae520020b13b7623085af21a /database.cc
parentf232f0a797b4fb657e630ca4bd664f9dcfe90dac (diff)
Add notmuch_status_to_string function.
Be kind and let the user print error messages, not just error codes.
Diffstat (limited to 'database.cc')
-rw-r--r--database.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/database.cc b/database.cc
index b5986627..5049b47e 100644
--- a/database.cc
+++ b/database.cc
@@ -28,6 +28,26 @@
using namespace std;
+const char *
+notmuch_status_to_string (notmuch_status_t status)
+{
+ switch (status) {
+ case NOTMUCH_STATUS_SUCCESS:
+ return "No error occurred";
+ case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
+ return "A Xapian exception occurred";
+ case NOTMUCH_STATUS_FILE_NOT_EMAIL:
+ return "File is not an email";
+ case NOTMUCH_STATUS_NULL_POINTER:
+ return "Erroneous NULL pointer";
+ case NOTMUCH_STATUS_TAG_TOO_LONG:
+ return "Tag value is too long";
+ default:
+ case NOTMUCH_STATUS_LAST_STATUS:
+ return "Unknown error status value";
+ }
+}
+
/* "128 bits of thread-id ought to be enough for anybody" */
#define NOTMUCH_THREAD_ID_BITS 128
#define NOTMUCH_THREAD_ID_DIGITS (NOTMUCH_THREAD_ID_BITS / 4)