From b9b3e7a925e4466ad5e1de7b0176dae1bb5ab153 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Wed, 21 Feb 2024 12:06:11 +0100 Subject: [PATCH] ApiListener: Catch & supress clients runtime errors --- lib/remote/apilistener.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 401ccb63e..2162c2120 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -1022,7 +1022,12 @@ void ApiListener::ApiTimerHandler() for (const JsonRpcConnection::Ptr& client : endpoint->GetClients()) { if (client->GetTimestamp() == maxTs) { - client->SendMessage(lmessage); + try { + client->SendMessage(lmessage); + } catch (const std::runtime_error& ex) { + Log(LogNotice, "ApiListener") + << "Error while setting log position for identity '" << endpoint->GetName() << "': " << DiagnosticInformation(ex, false); + } } else { client->Disconnect(); } @@ -1194,7 +1199,12 @@ void ApiListener::SyncSendMessage(const Endpoint::Ptr& endpoint, const Dictionar if (client->GetTimestamp() != maxTs) continue; - client->SendMessage(message); + try { + client->SendMessage(message); + } catch (const std::runtime_error& ex) { + Log(LogNotice, "ApiListener") + << "Error while sending message to endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex, false); + } } } }