diff options
author | Jose <jose@zeroc.com> | 2017-09-20 11:05:13 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2017-09-20 11:05:13 +0200 |
commit | 7f0816001e085f482f8f9a34b7f8e06435907510 (patch) | |
tree | 46807f18b840e1c9816cd9b4aac001c8078d8bce /cpp/src/Ice/StreamSocket.cpp | |
parent | Fixed Ice/acm Java7 build failure (diff) | |
download | ice-7f0816001e085f482f8f9a34b7f8e06435907510.tar.bz2 ice-7f0816001e085f482f8f9a34b7f8e06435907510.tar.xz ice-7f0816001e085f482f8f9a34b7f8e06435907510.zip |
Clean C++ exception code to only throw exception types
- Update C++ code to only throw types derived from
C++ exception
- Update C++ code to use one-shot constructors to
create the exceptions
Fix bug ICE-7892
Diffstat (limited to 'cpp/src/Ice/StreamSocket.cpp')
-rwxr-xr-x | cpp/src/Ice/StreamSocket.cpp | 64 |
1 files changed, 16 insertions, 48 deletions
diff --git a/cpp/src/Ice/StreamSocket.cpp b/cpp/src/Ice/StreamSocket.cpp index 912916e5ed3..80a45355bb0 100755 --- a/cpp/src/Ice/StreamSocket.cpp +++ b/cpp/src/Ice/StreamSocket.cpp @@ -246,9 +246,7 @@ StreamSocket::read(char* buf, size_t length) #endif if(ret == 0) { - Ice::ConnectionLostException ex(__FILE__, __LINE__); - ex.error = 0; - throw ex; + throw Ice::ConnectionLostException(__FILE__, __LINE__, 0); } else if(ret == SOCKET_ERROR) { @@ -270,15 +268,11 @@ StreamSocket::read(char* buf, size_t length) if(connectionLost()) { - Ice::ConnectionLostException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::ConnectionLostException(__FILE__, __LINE__, getSocketErrno()); } else { - Ice::SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::SocketException(__FILE__, __LINE__, getSocketErrno()); } } @@ -319,9 +313,7 @@ StreamSocket::write(const char* buf, size_t length) #endif if(ret == 0) { - Ice::ConnectionLostException ex(__FILE__, __LINE__); - ex.error = 0; - throw ex; + throw Ice::ConnectionLostException(__FILE__, __LINE__, 0); } else if(ret == SOCKET_ERROR) { @@ -343,15 +335,11 @@ StreamSocket::write(const char* buf, size_t length) if(connectionLost()) { - Ice::ConnectionLostException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::ConnectionLostException(__FILE__, __LINE__, getSocketErrno()); } else { - Ice::SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::SocketException(__FILE__, __LINE__, getSocketErrno()); } } @@ -409,15 +397,11 @@ StreamSocket::startWrite(Buffer& buf) { if(connectionLost()) { - Ice::ConnectionLostException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::ConnectionLostException(__FILE__, __LINE__, getSocketErrno()); } else { - Ice::SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::SocketException(__FILE__, __LINE__, getSocketErrno()); } } } @@ -437,15 +421,11 @@ StreamSocket::finishWrite(Buffer& buf) WSASetLastError(_write.error); if(connectionLost()) { - Ice::ConnectionLostException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::ConnectionLostException(__FILE__, __LINE__, getSocketErrno()); } else { - Ice::SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::SocketException(__FILE__, __LINE__, getSocketErrno()); } } @@ -472,15 +452,11 @@ StreamSocket::startRead(Buffer& buf) { if(connectionLost()) { - Ice::ConnectionLostException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::ConnectionLostException(__FILE__, __LINE__, getSocketErrno()); } else { - Ice::SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::SocketException(__FILE__, __LINE__, getSocketErrno()); } } } @@ -499,22 +475,16 @@ StreamSocket::finishRead(Buffer& buf) WSASetLastError(_read.error); if(connectionLost()) { - Ice::ConnectionLostException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::ConnectionLostException(__FILE__, __LINE__, getSocketErrno()); } else { - Ice::SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; + throw Ice::SocketException(__FILE__, __LINE__, getSocketErrno()); } } else if(_read.count == 0) { - Ice::ConnectionLostException ex(__FILE__, __LINE__); - ex.error = 0; - throw ex; + throw Ice::ConnectionLostException(__FILE__, __LINE__, 0); } buf.i += _read.count; @@ -620,9 +590,7 @@ StreamSocket::finishRead(Buffer& buf) } else if(_read.count == 0) { - Ice::ConnectionLostException ex(__FILE__, __LINE__); - ex.error = 0; - throw ex; + throw Ice::ConnectionLostException(__FILE__, __LINE__, 0); } try |