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/Service.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/Service.cpp')
-rw-r--r-- | cpp/src/Ice/Service.cpp | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index 260ce660ed5..324abfc1115 100644 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -221,9 +221,7 @@ public: _source = RegisterEventSourceW(0, stringToWstring(mangleSource(source), _stringConverter).c_str()); if(_source == 0) { - SyscallException ex(__FILE__, __LINE__); - ex.error = GetLastError(); - throw ex; + throw SyscallException(__FILE__, __LINE__, GetLastError()); } } @@ -248,9 +246,7 @@ public: if(err != ERROR_SUCCESS) { - SyscallException ex(__FILE__, __LINE__); - ex.error = err; - throw ex; + throw SyscallException(__FILE__, __LINE__, err); } // @@ -261,9 +257,7 @@ public: if(!GetModuleFileNameW(_module, path, _MAX_PATH)) { RegCloseKey(hKey); - SyscallException ex(__FILE__, __LINE__); - ex.error = GetLastError(); - throw ex; + throw SyscallException(__FILE__, __LINE__, GetLastError()); } // @@ -287,9 +281,7 @@ public: if(err != ERROR_SUCCESS) { RegCloseKey(hKey); - SyscallException ex(__FILE__, __LINE__); - ex.error = err; - throw ex; + throw SyscallException(__FILE__, __LINE__, err); } RegCloseKey(hKey); @@ -306,9 +298,7 @@ public: stringToWstring(createKey(source), stringConverter).c_str()); if(err != ERROR_SUCCESS) { - SyscallException ex(__FILE__, __LINE__); - ex.error = err; - throw ex; + throw SyscallException(__FILE__, __LINE__, err); } } @@ -1620,9 +1610,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa // if(setsid() == -1) { - SyscallException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSystemErrno(); - throw ex; + throw SyscallException(__FILE__, __LINE__, IceInternal::getSystemErrno()); } // @@ -1637,9 +1625,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa pid = fork(); if(pid < 0) { - SyscallException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSystemErrno(); - throw ex; + throw SyscallException(__FILE__, __LINE__, IceInternal::getSystemErrno()); } if(pid != 0) { @@ -1653,9 +1639,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa // if(chdir("/") != 0) { - SyscallException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSystemErrno(); - throw ex; + throw SyscallException(__FILE__, __LINE__, IceInternal::getSystemErrno()); } } @@ -1671,9 +1655,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa int fdMax = static_cast<int>(sysconf(_SC_OPEN_MAX)); if(fdMax <= 0) { - SyscallException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSystemErrno(); - throw ex; + throw SyscallException(__FILE__, __LINE__, IceInternal::getSystemErrno()); } for(int i = 0; i < fdMax; ++i) @@ -1733,9 +1715,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa assert(fd == 0); if(fd != 0) { - SyscallException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSystemErrno(); - throw ex; + throw SyscallException(__FILE__, __LINE__, IceInternal::getSystemErrno()); } if(stdOut.empty()) { @@ -1743,9 +1723,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa assert(fd == 1); if(fd != 1) { - SyscallException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSystemErrno(); - throw ex; + throw SyscallException(__FILE__, __LINE__, IceInternal::getSystemErrno()); } } if(stdErr.empty()) @@ -1754,9 +1732,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa assert(fd == 2); if(fd != 2) { - SyscallException ex(__FILE__, __LINE__); - ex.error = IceInternal::getSystemErrno(); - throw ex; + throw SyscallException(__FILE__, __LINE__, IceInternal::getSystemErrno()); } } } |