summaryrefslogtreecommitdiff
path: root/src/conn/api_strerror.c
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2014-06-24 10:06:07 -0400
committerKeith Bostic <keith@wiredtiger.com>2014-06-24 10:06:07 -0400
commit2ef3de771b23bfc10902bde8c53f1e8ef4997845 (patch)
treeaacca5d481c3b6a27dc35ef1f13b1239001c8355 /src/conn/api_strerror.c
parent17dfa754f587e2c5dccda856f39adfd06be94344 (diff)
downloadmongo-2ef3de771b23bfc10902bde8c53f1e8ef4997845.tar.gz
Minor futzing with the LevelDB copyright checks, add a WiredTiger
copyright notice to the leveldb/port/ files (such as they are). Move src/api/api_XXX into src/conn/XXX, there's no reason to have an api directory in the lower level (and it's about 100 lines of code, anyway).
Diffstat (limited to 'src/conn/api_strerror.c')
-rw-r--r--src/conn/api_strerror.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/conn/api_strerror.c b/src/conn/api_strerror.c
new file mode 100644
index 00000000000..8cd410d4f01
--- /dev/null
+++ b/src/conn/api_strerror.c
@@ -0,0 +1,43 @@
+/* DO NOT EDIT: automatically built by dist/api_err.py. */
+
+#include "wt_internal.h"
+
+/*
+ * wiredtiger_strerror --
+ * Return a string for any error value.
+ */
+const char *
+wiredtiger_strerror(int error)
+{
+ static char errbuf[64];
+ char *p;
+
+ if (error == 0)
+ return ("Successful return: 0");
+
+ switch (error) {
+ case WT_DEADLOCK:
+ return ("WT_DEADLOCK: conflict between concurrent operations");
+ case WT_DUPLICATE_KEY:
+ return ("WT_DUPLICATE_KEY: attempt to insert an existing key");
+ case WT_ERROR:
+ return ("WT_ERROR: non-specific WiredTiger error");
+ case WT_NOTFOUND:
+ return ("WT_NOTFOUND: item not found");
+ case WT_PANIC:
+ return ("WT_PANIC: WiredTiger library panic");
+ case WT_RESTART:
+ return ("WT_RESTART: restart the operation (internal)");
+ default:
+ if (error > 0 && (p = strerror(error)) != NULL)
+ return (p);
+ break;
+ }
+
+ /*
+ * !!!
+ * Not thread-safe, but this is never supposed to happen.
+ */
+ (void)snprintf(errbuf, sizeof(errbuf), "Unknown error: %d", error);
+ return (errbuf);
+}