Make critical connection errors readable in ApiListener.

Refs #6070
This commit is contained in:
Michael Friedrich 2014-05-22 13:45:42 +02:00
parent 7462c8320a
commit aaa6154fd7
1 changed files with 12 additions and 3 deletions

View File

@ -163,7 +163,8 @@ void ApiListener::ListenerThreadProc(const Socket::Ptr& server)
* @param node The remote host.
* @param service The remote port.
*/
void ApiListener::AddConnection(const String& node, const String& service) {
void ApiListener::AddConnection(const String& node, const String& service)
{
{
ObjectLock olock(this);
@ -175,8 +176,16 @@ void ApiListener::AddConnection(const String& node, const String& service) {
TcpSocket::Ptr client = make_shared<TcpSocket>();
client->Connect(node, service);
Utility::QueueAsyncCallback(boost::bind(&ApiListener::NewClientHandler, this, client, RoleClient));
try {
client->Connect(node, service);
Utility::QueueAsyncCallback(boost::bind(&ApiListener::NewClientHandler, this, client, RoleClient));
} catch (const std::exception& ex) {
std::ostringstream info, debug;
info << "Cannot connect to host '" << node << "' on port '" << service << "'.";
debug << info << std::endl << DiagnosticInformation(ex);
Log(LogCritical, "remote", info.str());
Log(LogDebug, "remote", debug.str());
}
}
/**