From 8a163875fbbb5db4372971859728235605de31b6 Mon Sep 17 00:00:00 2001 From: Emagi Date: Mon, 2 Dec 2024 19:40:15 -0500 Subject: [PATCH] exception handling with debug logs --- source/WorldServer/Web/HTTPSClientPool.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/source/WorldServer/Web/HTTPSClientPool.cpp b/source/WorldServer/Web/HTTPSClientPool.cpp index ab68d0d..fe8a0fc 100644 --- a/source/WorldServer/Web/HTTPSClientPool.cpp +++ b/source/WorldServer/Web/HTTPSClientPool.cpp @@ -719,9 +719,21 @@ void HTTPSClientPool::startPolling() { auto server = clientPair.first.first; auto port = clientPair.first.second; LogWrite(PEERING__DEBUG, 5, "Peering", "%s: startPolling for %s:%s.", __FUNCTION__, server.c_str(), port.c_str()); - std::async(std::launch::async, [this, server, port]() { - pollPeerHealth(server, port); - }); + try { + std::async(std::launch::async, [this, server, port]() { + try { + pollPeerHealth(server, port); + } catch (const std::exception& e) { + LogWrite(PEERING__DEBUG, 1, "Peering", "Exception in pollPeerHealth for %s:%s: %s", server.c_str(), port.c_str(), e.what()); + } catch (...) { + LogWrite(PEERING__DEBUG, 1, "Peering", "Unknown exception in pollPeerHealth for %s:%s.", server.c_str(), port.c_str()); + } + }); + } catch (const std::exception& e) { + LogWrite(PEERING__DEBUG, 1, "Peering", "Failed to start async task for %s:%s: %s", server.c_str(), port.c_str(), e.what()); + } catch (...) { + LogWrite(PEERING__DEBUG, 1, "Peering", "Unknown exception when starting async task for %s:%s.", server.c_str(), port.c_str()); + } } }