From aaa6154fd772a1ce95869f2b273fb2f9f65b441f Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 22 May 2014 13:45:42 +0200 Subject: [PATCH] Make critical connection errors readable in ApiListener. Refs #6070 --- lib/remote/apilistener.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 60dbb14be..1612e749c 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -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(); - 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()); + } } /**