remove ERR_READ_EOF, add more general errors, add missing _general_error_desc, and have error_name return for SUCCESS
--- a/src/error.c Sun May 03 17:15:45 2009 +0300
+++ b/src/error.c Sun May 03 17:16:30 2009 +0300
@@ -27,7 +27,6 @@
{ ERR_SOCKET, "socket", ERR_EXTRA_ERRNO },
{ ERR_CONNECT, "connect", ERR_EXTRA_ERRNO },
{ ERR_READ, "read", ERR_EXTRA_ERRNO },
- { ERR_READ_EOF, "read: EOF", ERR_EXTRA_NONE },
{ ERR_WRITE, "write", ERR_EXTRA_ERRNO },
{ ERR_WRITE_EOF, "write: EOF", ERR_EXTRA_NONE },
{ ERR_FCNTL, "fcntl", ERR_EXTRA_ERRNO },
@@ -100,6 +99,8 @@
{ ERR_CMD_OPT, "invalid command line option", ERR_EXTRA_STR },
{ ERR_DUP_NAME, "duplicate name", ERR_EXTRA_STR },
{ ERR_EOF, "EOF", ERR_EXTRA_NONE },
+ { ERR_MEM, "memory allocation error", ERR_EXTRA_NONE },
+ { ERR_NOT_IMPLEMENTED, "function not implemented", ERR_EXTRA_NONE },
{ _ERR_INVALID, NULL, 0 }
};
@@ -115,6 +116,7 @@
_module_error_desc,
_lua_error_desc,
_pcre_error_desc,
+ _general_error_desc,
NULL
};
@@ -143,9 +145,14 @@
{
const struct error_desc *desc;
- // do we have an error_desc for it?
- if ((desc = error_lookup_desc(code)))
+ if (!code)
+ // no error...
+ return "success";
+
+ else if ((desc = error_lookup_desc(code)))
+ // found an error_desc for it
return desc->name;
+
else
// unknown
return "[unknown]";
--- a/src/error.h Sun May 03 17:15:45 2009 +0300
+++ b/src/error.h Sun May 03 17:16:30 2009 +0300
@@ -57,7 +57,6 @@
ERR_SOCKET, ///< socket(2) failed
ERR_CONNECT, ///< connect(2) error - either direct or async
ERR_READ, ///< read(2) error - will probably show up as an ERR_WRITE as well
- ERR_READ_EOF, ///< EOF on read(2)
ERR_WRITE, ///< write(2) error - data was unsent, will probably show up as an ERR_READ as well
ERR_WRITE_EOF, ///< write(2) gave EOF - zero bytes written
ERR_FCNTL, ///< fcntl(2) failed
@@ -137,7 +136,8 @@
ERR_UNKNOWN,
ERR_DUP_NAME, ///< duplicate name
ERR_EOF, ///< end of file
-
+ ERR_MEM, ///< memory allocation error
+ ERR_NOT_IMPLEMENTED, ///< function not implemented
};
/**