aboutsummaryrefslogtreecommitdiff
path: root/status.c
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2016-11-27 23:01:42 -0400
committerDavid Bremner <david@tethera.net>2016-12-07 07:00:40 -0400
commitd74c5345704136611f993ca38e0d035b1da798b6 (patch)
treea9d5383e410994bb0261d704fe1a102f9639e1d7 /status.c
parent9259b97fa2659ae6b6dbcd49b04db087e64036ad (diff)
cli/insert: return EX_TEMPFAIL for some errors
Attempt to distinguish between errors indicating misconfiguration or programmer error, which we consider "permanent", in the sense that automatic retries are unlikely to be useful, and those indicating transient error conditions. We consider XAPIAN_EXCEPTION transient because it covers the important special case of locking failure.
Diffstat (limited to 'status.c')
-rw-r--r--status.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/status.c b/status.c
index 45d3fb4e..8bc2fe4b 100644
--- a/status.c
+++ b/status.c
@@ -36,3 +36,19 @@ print_status_database (const char *loc,
}
return status;
}
+
+int
+status_to_exit (notmuch_status_t status)
+{
+ switch (status) {
+ case NOTMUCH_STATUS_SUCCESS:
+ return EXIT_SUCCESS;
+ case NOTMUCH_STATUS_OUT_OF_MEMORY:
+ case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
+ case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
+ case NOTMUCH_STATUS_FILE_ERROR:
+ return EX_TEMPFAIL;
+ default:
+ return EXIT_FAILURE;
+ }
+}