From 5582eefae6085c2893dd8c5240e2b9dcec4a3915 Mon Sep 17 00:00:00 2001 From: Dario Date: Fri, 21 Aug 2020 17:06:39 +0200 Subject: [PATCH] add try and catch for reconnect attempt --- src/cpp/SingletonManager/ConnectionManager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cpp/SingletonManager/ConnectionManager.cpp b/src/cpp/SingletonManager/ConnectionManager.cpp index c8752ee6e..a86f41f60 100644 --- a/src/cpp/SingletonManager/ConnectionManager.cpp +++ b/src/cpp/SingletonManager/ConnectionManager.cpp @@ -75,7 +75,14 @@ Poco::Data::Session ConnectionManager::getConnection(ConnectionType type) auto session = mSessionPools.getPool(mSessionPoolNames[type]).get(); if (!session.isConnected()) { printf("reconnect called\n"); - session.reconnect(); + try { + session.reconnect(); + } + catch (Poco::Exception& e) { + addError(new ParamError("[ConnectionManager::getConnection]", "reconnect throw exception, try with next new one, without further check", e.displayText())); + sendErrorsAsEmail(); + return mSessionPools.getPool(mSessionPoolNames[type]).get(); + } } //std::string dateTimeString = Poco::DateTimeFormatter::format(Poco::DateTime(), "%d.%m.%y %H:%M:%S"); //printf("[getConnection] %s impl: %p\n", dateTimeString.data(), session.impl());