diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-04-15 22:03:00 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-04-15 22:03:00 +0000 |
commit | 16bfb3c7f6335d988ebf907ac823418a592f58e3 (patch) | |
tree | d0c9b29ece4f82353bc4c64134c7d8dd50ac0811 /lib/server | |
parent | 71a4ffb7fbdf9775f7d1a2f79633173cb08e1aa2 (diff) |
Define BOX_SOCKET_ERROR_MESSAGE, replace more BOX_LOG_SOCKET_ERROR calls with it.
Diffstat (limited to 'lib/server')
-rw-r--r-- | lib/server/SocketStream.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/server/SocketStream.cpp b/lib/server/SocketStream.cpp index a035898d..edb5e5b8 100644 --- a/lib/server/SocketStream.cpp +++ b/lib/server/SocketStream.cpp @@ -176,25 +176,31 @@ void SocketStream::Open(Socket::Type Type, const std::string& rName, int Port) 0 /* let OS choose protocol */); if(mSocketHandle == INVALID_SOCKET_VALUE) { - BOX_LOG_SOCKET_ERROR(Type, rName, Port, - "Failed to create a network socket"); - THROW_EXCEPTION(ServerException, SocketOpenError) + THROW_EXCEPTION_MESSAGE(ServerException, SocketOpenError, + BOX_SOCKET_ERROR_MESSAGE(Type, rName, Port, + "Failed to create a network socket")); } // Connect it if(::connect(mSocketHandle, &addr.sa_generic, addrLen) == -1) { // Dispose of the socket - BOX_LOG_SOCKET_ERROR(Type, rName, Port, - "Failed to connect to socket"); + try + { + THROW_EXCEPTION_MESSAGE(ServerException, SocketOpenError, + BOX_SOCKET_ERROR_MESSAGE(Type, rName, Port, + "Failed to connect to socket")); + } + catch(ServerException &e) + { #ifdef WIN32 - ::closesocket(mSocketHandle); + ::closesocket(mSocketHandle); #else // !WIN32 - ::close(mSocketHandle); + ::close(mSocketHandle); #endif // WIN32 - - mSocketHandle = INVALID_SOCKET_VALUE; - THROW_EXCEPTION(ConnectionException, SocketConnectError) + mSocketHandle = INVALID_SOCKET_VALUE; + throw; + } } ResetCounters(); |