mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +01:00
Add notmuch_status_to_string function.
Be kind and let the user print error messages, not just error codes.
This commit is contained in:
parent
f232f0a797
commit
302d54834d
3 changed files with 35 additions and 1 deletions
20
database.cc
20
database.cc
|
@ -28,6 +28,26 @@
|
||||||
|
|
||||||
using namespace std;
|
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" */
|
/* "128 bits of thread-id ought to be enough for anybody" */
|
||||||
#define NOTMUCH_THREAD_ID_BITS 128
|
#define NOTMUCH_THREAD_ID_BITS 128
|
||||||
#define NOTMUCH_THREAD_ID_DIGITS (NOTMUCH_THREAD_ID_BITS / 4)
|
#define NOTMUCH_THREAD_ID_DIGITS (NOTMUCH_THREAD_ID_BITS / 4)
|
||||||
|
|
|
@ -527,8 +527,11 @@ restore_command (int argc, char *argv[])
|
||||||
continue;
|
continue;
|
||||||
status = notmuch_message_add_tag (message, tag);
|
status = notmuch_message_add_tag (message, tag);
|
||||||
if (status) {
|
if (status) {
|
||||||
fprintf (stderr, "Error applying tag %s to message %s.\n",
|
fprintf (stderr,
|
||||||
|
"Error applying tag %s to message %s:\n",
|
||||||
tag, message_id);
|
tag, message_id);
|
||||||
|
fprintf (stderr, "%s\n",
|
||||||
|
notmuch_status_to_string (status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
notmuch.h
11
notmuch.h
|
@ -49,6 +49,10 @@ typedef int notmuch_bool_t;
|
||||||
*
|
*
|
||||||
* NOTMUCH_STATUS_SUCCESS: No error occurred.
|
* NOTMUCH_STATUS_SUCCESS: No error occurred.
|
||||||
*
|
*
|
||||||
|
* XXX: We don't really want to expose this lame XAPIAN_EXCEPTION
|
||||||
|
* value. Instead we should map to things like DATABASE_LOCKED or
|
||||||
|
* whatever.
|
||||||
|
*
|
||||||
* NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
|
* NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
|
||||||
*
|
*
|
||||||
* NOTMUCH_STATUS_FILE_NOT_EMAIL: A file was presented that doesn't
|
* NOTMUCH_STATUS_FILE_NOT_EMAIL: A file was presented that doesn't
|
||||||
|
@ -72,6 +76,13 @@ typedef enum _notmuch_status {
|
||||||
NOTMUCH_STATUS_LAST_STATUS
|
NOTMUCH_STATUS_LAST_STATUS
|
||||||
} notmuch_status_t;
|
} notmuch_status_t;
|
||||||
|
|
||||||
|
/* Get a string representation of a notmuch_status_t value.
|
||||||
|
*
|
||||||
|
* The result is readonly.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
notmuch_status_to_string (notmuch_status_t status);
|
||||||
|
|
||||||
/* Various opaque data types. For each notmuch_<foo>_t see the various
|
/* Various opaque data types. For each notmuch_<foo>_t see the various
|
||||||
* notmuch_<foo> functions below. */
|
* notmuch_<foo> functions below. */
|
||||||
typedef struct _notmuch_database notmuch_database_t;
|
typedef struct _notmuch_database notmuch_database_t;
|
||||||
|
|
Loading…
Reference in a new issue