diff options
author | Marc Laukien <marc@zeroc.com> | 2001-08-23 20:50:55 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-08-23 20:50:55 +0000 |
commit | 5191b8f95031ad12fb12b6ac56c53e51c1bb8681 (patch) | |
tree | 577f44e1ceda4a60ad686d96f1cd5c922e32b616 /cpp/src | |
parent | fix (diff) | |
download | ice-5191b8f95031ad12fb12b6ac56c53e51c1bb8681.tar.bz2 ice-5191b8f95031ad12fb12b6ac56c53e51c1bb8681.tar.xz ice-5191b8f95031ad12fb12b6ac56c53e51c1bb8681.zip |
added missing config files; better error messages
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/LocalException.cpp | 9 | ||||
-rw-r--r-- | cpp/src/Ice/Network.cpp | 31 | ||||
-rw-r--r-- | cpp/src/Ice/Network.h | 8 |
3 files changed, 35 insertions, 13 deletions
diff --git a/cpp/src/Ice/LocalException.cpp b/cpp/src/Ice/LocalException.cpp index 2a63fa5f75a..b8e2b1a62c8 100644 --- a/cpp/src/Ice/LocalException.cpp +++ b/cpp/src/Ice/LocalException.cpp @@ -513,7 +513,7 @@ Ice::SystemException::SystemException(const char* file, int line) : LocalException(file, line) { #ifdef WIN32 - _error = WSAGetLastError(); + _error = GetLastError(); #else _error = errno; #endif @@ -559,6 +559,13 @@ Ice::SystemException::raise() const Ice::SocketException::SocketException(const char* file, int line) : SystemException(file, line) { +#ifdef WIN32 + // + // Overwrite _error, which has been set by GetLastError() in the + // SystemException constructor, with WSAGetLastError() + // + _error = WSAGetLastError(); +#endif } Ice::SocketException::SocketException(const SocketException& ex) : diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 34d88b86045..94a5c947ed4 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -617,9 +617,24 @@ IceInternal::createPipe(int fds[2]) #ifdef WIN32 -const char* +string IceInternal::errorToString(int error) { + if (error < WSABASEERR) + { + LPVOID lpMsgBuf; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + error, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR)&lpMsgBuf, + 0, + NULL); + string result = (LPCTSTR)lpMsgBuf; + LocalFree( lpMsgBuf ); + return result; + } + switch (error) { case WSAEINTR: @@ -776,11 +791,11 @@ IceInternal::errorToString(int error) return "WSANO_DATA"; default: - return "unknown error"; + return "unknown socket error"; } } -const char* +string IceInternal::errorToStringDNS(int error) { return errorToString(error); @@ -788,13 +803,13 @@ IceInternal::errorToStringDNS(int error) #else -const char* +string IceInternal::errorToString(int error) { return strerror(error); } -const char* +string IceInternal::errorToStringDNS(int error) { switch (error) @@ -818,13 +833,13 @@ IceInternal::errorToStringDNS(int error) return "name has no IP address"; default: - return "unknown error"; + return "unknown DNS error"; } } #endif -const char* +string IceInternal::lastErrorToString() { #ifdef WIN32 @@ -834,7 +849,7 @@ IceInternal::lastErrorToString() #endif } -const char* +string IceInternal::lastErrorToStringDNS() { #ifdef WIN32 diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index 90c64816eab..e102cdcab63 100644 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -89,10 +89,10 @@ std::string getLocalHost(bool); void createPipe(int fds[2]); -const char* errorToString(int); -const char* errorToStringDNS(int); -const char* lastErrorToString(); -const char* lastErrorToStringDNS(); +std::string errorToString(int); +std::string errorToStringDNS(int); +std::string lastErrorToString(); +std::string lastErrorToStringDNS(); std::string fdToString(int); std::string addrToString(const struct sockaddr_in&); |