summaryrefslogtreecommitdiff
path: root/src/support/strerror.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/support/strerror.c')
-rw-r--r--src/support/strerror.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/support/strerror.c b/src/support/strerror.c
new file mode 100644
index 00000000000..17a4653438a
--- /dev/null
+++ b/src/support/strerror.c
@@ -0,0 +1,41 @@
+/* DO NOT EDIT: automatically built by dist/api_err.py. */
+
+#include "wt_internal.h"
+
+/*
+ * wiredtiger_strerror --
+ * Return a string for any error value.
+ */
+char *
+wiredtiger_strerror(int error)
+{
+ static char errbuf[64];
+ char *p;
+
+ if (error == 0)
+ return ("Successful return: 0");
+
+ switch (error) {
+ case WT_ERROR:
+ return ("WT_ERROR: non-specific WiredTiger error");
+ case WT_NOTFOUND:
+ return ("WT_NOTFOUND: database item not found");
+ case WT_READONLY:
+ return ("WT_READONLY: modification attempted of a read-only database");
+ case WT_RESTART:
+ return ("WT_RESTART: restart the operation (internal)");
+ case WT_TOOSMALL:
+ return ("WT_TOOSMALL: buffer too small");
+ 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);
+}