18 static WvErrMap wverrmap[] = {
19 { WSAEINTR,
"Interrupted" },
20 { WSAEBADF,
"Bad file descriptor" },
21 { WSAEACCES,
"Access denied" },
22 { WSAEFAULT,
"Bad address" },
23 { WSAEINVAL,
"Invalid argument" },
24 { WSAEMFILE,
"Too many open files" },
25 { WSAEWOULDBLOCK,
"Operation would block" },
26 { WSAEINPROGRESS,
"Operation now in progress" },
27 { WSAEALREADY,
"Operation already in progress" },
28 { WSAENOTSOCK,
"Socket operation on non-socket" },
29 { WSAEDESTADDRREQ,
"Destination address required" },
30 { WSAEMSGSIZE,
"Message too long" },
31 { WSAEPROTOTYPE,
"Protocol wrong type for socket" },
32 { WSAENOPROTOOPT,
"Protocol not available" },
33 { WSAEPROTONOSUPPORT,
"Protocol not supported" },
34 { WSAESOCKTNOSUPPORT,
"Socket type not supported" },
35 { WSAEOPNOTSUPP,
"Operation not supported on transport endpoint" },
36 { WSAEPFNOSUPPORT,
"Protocol family not supported" },
37 { WSAEAFNOSUPPORT,
"Address family not supported by protocol" },
38 { WSAEADDRINUSE,
"Address already in use" },
39 { WSAEADDRNOTAVAIL,
"Cannot assign requested address" },
40 { WSAENETDOWN,
"Network is down" },
41 { WSAENETUNREACH,
"Network is unreachable" },
42 { WSAENETRESET,
"Network dropped connection because of reset" },
43 { WSAECONNABORTED,
"Software caused connection abort" },
44 { WSAECONNRESET,
"Connection reset by peer" },
45 { WSAENOBUFS,
"No buffer space available" },
46 { WSAEISCONN,
"Transport endpoint is already connected" },
47 { WSAENOTCONN,
"Transport endpoint is not connected" },
48 { WSAESHUTDOWN,
"Cannot send after transport endpoint shutdown" },
49 { WSAETOOMANYREFS,
"Too many references: cannot splice" },
50 { WSAETIMEDOUT,
"Connection timed out" },
51 { WSAECONNREFUSED,
"Connection refused" },
52 { WSAELOOP,
"Too many symbolic links encountered" },
53 { WSAENAMETOOLONG,
"File name too long" },
54 { WSAEHOSTDOWN,
"Host is down" },
55 { WSAEHOSTUNREACH,
"No route to host" },
56 { WSAENOTEMPTY,
"Directory not empty" },
57 { WSAEPROCLIM,
"Process limit reached" },
58 { WSAEUSERS,
"Too many users" },
59 { WSAEDQUOT,
"Disk quota exceeded" },
60 { WSAESTALE,
"Stale file handle" },
61 { WSAEREMOTE,
"Object is remote" },
62 { WSAEDISCON,
"Disconnected" },
63 { WSAENOMORE,
"No more data" },
64 { WSAECANCELLED,
"Operation cancelled" },
65 { WSAEINVALIDPROCTABLE,
"Invalid process table" },
66 { WSAEINVALIDPROVIDER,
"Invalid provider" },
67 { WSAEPROVIDERFAILEDINIT,
"Provider failed to initialize" },
68 { WSAEREFUSED,
"Operation refused" },
72 static const char *wv_errmap(
int errnum)
75 for (WvErrMap *i = wverrmap; i->num; i++)
83 WvErrorBase::~WvErrorBase()
96 return ::strerror(errnum);
98 const char *wverr = wv_errmap(errnum);
101 else if (errnum >= WSABASEERR && errnum < WSABASEERR+2000)
106 const HMODULE module = GetModuleHandle(
"winsock.dll");
107 DWORD result = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
108 module, errnum, 0, msg,
sizeof(msg), 0);
112 DWORD e = GetLastError();
113 return WvString(
"Unknown format %s for error %s", e, errnum);
118 if (!strcmp(str,
"Unknown error"))
119 return WvString(
"Unknown win32 error #%s", errnum);
127 WvString WvErrorBase::errstr()
const
138 if (!!errstring)
return errstring;
148 assert((_errnum != -1 || !!errstring)
149 &&
"attempt to set errnum to -1 without also setting errstring");
151 if (_errnum == WSAECONNABORTED)
152 _errnum = WSAECONNREFUSED;
161 assert(!!specialerr);
164 errstring = specialerr;
174 else if (err.
geterr() < 0)
179 void WvErrorBase::seterr_both(
int _errnum, WvStringParm specialerr)
181 assert(!!specialerr);
184 errstring = specialerr;