Use const-ref specifier when catching exceptions

refs #6070
This commit is contained in:
Gunnar Beutner 2014-08-25 08:35:35 +02:00
parent 2c7f440a73
commit f7f8bd9b00
9 changed files with 26 additions and 26 deletions

View File

@ -95,7 +95,7 @@ void Application::Stop(void)
if (l_Restarting) {
try {
UpdatePidFile(GetPidPath(), m_ReloadProcess);
} catch (std::exception&) {
} catch (const std::exception&) {
/* abort restart */
Log(LogCritical, "Application", "Cannot update PID file. Aborting restart operation.");
return;
@ -667,7 +667,7 @@ int Application::Run(void)
try {
UpdatePidFile(GetPidPath());
} catch (std::exception&) {
} catch (const std::exception&) {
Log(LogCritical, "Application", "Cannot update PID file '" + GetPidPath() + "'. Aborting.");
return false;
}

View File

@ -40,7 +40,7 @@ public:
{
try {
return boost::lexical_cast<long>(val);
} catch (std::exception&) {
} catch (const std::exception&) {
std::ostringstream msgbuf;
msgbuf << "Can't convert '" << val << "' to an integer.";
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));
@ -52,7 +52,7 @@ public:
{
try {
return boost::lexical_cast<double>(val);
} catch (std::exception&) {
} catch (const std::exception&) {
std::ostringstream msgbuf;
msgbuf << "Can't convert '" << val << "' to a floating point number.";
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));

View File

@ -128,7 +128,7 @@ LogSeverity Logger::GetMinSeverity(void) const
try {
ls = Logger::StringToSeverity(severity);
} catch (std::exception&) { /* use the default level */ }
} catch (const std::exception&) { /* use the default level */ }
return ls;
}

View File

@ -189,7 +189,7 @@ String Socket::GetClientAddress(void)
String address;
try {
address = GetAddressFromSockaddr((sockaddr *)&sin, len);
} catch (std::exception&) {
} catch (const std::exception&) {
/* already logged */
}
@ -231,7 +231,7 @@ String Socket::GetPeerAddress(void)
String address;
try {
address = GetAddressFromSockaddr((sockaddr *)&sin, len);
} catch (std::exception&) {
} catch (const std::exception&) {
/* already logged */
}

View File

@ -122,7 +122,7 @@ void StreamLogger::ProcessLogEntry(std::ostream& stream, bool tty, const LogEntr
try {
stream << Logger::SeverityToString(entry.Severity);
} catch (std::exception&) {
} catch (const std::exception&) {
/* bail early */
return;
}

View File

@ -115,12 +115,12 @@ void TlsStream::Handshake(void)
case SSL_ERROR_WANT_READ:
try {
m_Socket->Poll(true, false);
} catch (std::exception&) {}
} catch (const std::exception&) {}
continue;
case SSL_ERROR_WANT_WRITE:
try {
m_Socket->Poll(false, true);
} catch (std::exception&) {}
} catch (const std::exception&) {}
continue;
case SSL_ERROR_ZERO_RETURN:
Close();
@ -161,12 +161,12 @@ size_t TlsStream::Read(void *buffer, size_t count)
case SSL_ERROR_WANT_READ:
try {
m_Socket->Poll(true, false);
} catch (std::exception&) {}
} catch (const std::exception&) {}
continue;
case SSL_ERROR_WANT_WRITE:
try {
m_Socket->Poll(false, true);
} catch (std::exception&) {}
} catch (const std::exception&) {}
continue;
case SSL_ERROR_ZERO_RETURN:
Close();
@ -209,12 +209,12 @@ void TlsStream::Write(const void *buffer, size_t count)
case SSL_ERROR_WANT_READ:
try {
m_Socket->Poll(true, false);
} catch (std::exception&) {}
} catch (const std::exception&) {}
continue;
case SSL_ERROR_WANT_WRITE:
try {
m_Socket->Poll(false, true);
} catch (std::exception&) {}
} catch (const std::exception&) {}
continue;
case SSL_ERROR_ZERO_RETURN:
Close();
@ -258,12 +258,12 @@ void TlsStream::Close(void)
case SSL_ERROR_WANT_READ:
try {
m_Socket->Poll(true, false);
} catch (std::exception&) {}
} catch (const std::exception&) {}
continue;
case SSL_ERROR_WANT_WRITE:
try {
m_Socket->Poll(false, true);
} catch (std::exception&) {}
} catch (const std::exception&) {}
continue;
default:
goto close_socket;

View File

@ -155,7 +155,7 @@ bool ApiClient::ProcessMessage(void)
BOOST_THROW_EXCEPTION(std::invalid_argument("Function '" + method + "' does not exist."));
resultMessage->Set("result", afunc->Invoke(origin, message->Get("params")));
} catch (std::exception& ex) {
} catch (const std::exception& ex) {
resultMessage->Set("error", DiagnosticInformation(ex));
}

View File

@ -135,7 +135,7 @@ void ApiListener::SyncZoneDirs(void) const
try {
SyncZoneDir(zone);
} catch (std::exception&) {
} catch (const std::exception&) {
continue;
}
}

View File

@ -45,14 +45,14 @@ void ApiListener::OnConfigLoaded(void)
shared_ptr<X509> cert = make_shared<X509>();
try {
cert = GetX509Certificate(GetCertPath());
} catch (std::exception&) {
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Cannot get certificate from cert path: '" + GetCertPath() + "'.");
Application::Exit(EXIT_FAILURE);
}
try {
SetIdentity(GetCertificateCN(cert));
} catch (std::exception&) {
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Cannot get certificate common name from cert path: '" + GetCertPath() + "'.");
Application::Exit(EXIT_FAILURE);
}
@ -61,7 +61,7 @@ void ApiListener::OnConfigLoaded(void)
try {
m_SSLContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath());
} catch (std::exception&) {
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Cannot make SSL context for cert path: '" + GetCertPath() + "' key path: '" + GetKeyPath() + "' ca path: '" + GetCaPath() + "'.");
Application::Exit(EXIT_FAILURE);
}
@ -69,7 +69,7 @@ void ApiListener::OnConfigLoaded(void)
if (!GetCrlPath().IsEmpty()) {
try {
AddCRLToSSLContext(m_SSLContext, GetCrlPath());
} catch (std::exception&) {
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Cannot add certificate revocation list to SSL context for crl path: '" + GetCrlPath() + "'.");
Application::Exit(EXIT_FAILURE);
}
@ -205,7 +205,7 @@ void ApiListener::ListenerThreadProc(const Socket::Ptr& server)
try {
Socket::Ptr client = server->Accept();
Utility::QueueAsyncCallback(boost::bind(&ApiListener::NewClientHandler, this, client, RoleServer));
} catch (std::exception&) {
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Cannot accept new connection.");
}
}
@ -268,7 +268,7 @@ void ApiListener::NewClientHandler(const Socket::Ptr& client, ConnectionRole rol
ObjectLock olock(this);
try {
tlsStream = make_shared<TlsStream>(client, role, m_SSLContext);
} catch (std::exception&) {
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Cannot create tls stream from client connection.");
return;
}
@ -276,7 +276,7 @@ void ApiListener::NewClientHandler(const Socket::Ptr& client, ConnectionRole rol
try {
tlsStream->Handshake();
} catch (std::exception) {
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Client TLS handshake failed.");
return;
}
@ -286,7 +286,7 @@ void ApiListener::NewClientHandler(const Socket::Ptr& client, ConnectionRole rol
try {
identity = GetCertificateCN(cert);
} catch (std::exception&) {
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Cannot get certificate common name from cert path: '" + GetCertPath() + "'.");
return;
}