dnxError.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00032 #include "dnxError.h"
00033
00034 #include <errno.h>
00035 #include <string.h>
00036
00037 #define elemcount(x) (sizeof(x)/sizeof(*(x)))
00038
00039 static dnxError gLastError = DNX_OK;
00043
00044
00045
00046
00047 dnxError dnxGetLastError(void) { return gLastError; }
00048
00049
00050
00051 void dnxSetLastError(dnxError eno) { gLastError = eno; }
00052
00053
00054
00055 char * dnxErrorString(dnxError eno)
00056 {
00057 static char * errCatalog[] =
00058 {
00059 "A-OK, Okey-Dokey, Rock-On",
00060 "Invalid value",
00061 "Resource is exhausted",
00062 "Invalid or malformed URL",
00063 "Resource is already initialized/deinitialized",
00064 "Resource already exists",
00065 "Unsupported operation",
00066 "Out of memory",
00067 "Channel open error",
00068 "Message size is out of bounds",
00069 "Message transmission failure",
00070 "Message reception failure",
00071 "Invalid communications address",
00072 "Resource was not found",
00073 "Incorrect or invalid text",
00074 "Threading error",
00075 "Timeout error",
00076 "Resource is busy",
00077 "Access denied",
00078 };
00079
00080
00081 if (eno < DNX_ERR_BASE)
00082 return strerror(eno);
00083
00084
00085 eno -= DNX_ERR_BASE;
00086 return (char *)((eno < 0 || eno >= elemcount(errCatalog)) ?
00087 "Unknown error code" : errCatalog[eno]);
00088 }
00089
00090
00091