Skip to content

Commit 0c7c7ba

Browse files
committed
ApiListener: Catch & supress clients runtime errors
1 parent 5ff044a commit 0c7c7ba

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/remote/apilistener.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,12 @@ void ApiListener::ApiTimerHandler()
10231023

10241024
for (const JsonRpcConnection::Ptr& client : endpoint->GetClients()) {
10251025
if (client->GetTimestamp() == maxTs) {
1026-
client->SendMessage(lmessage);
1026+
try {
1027+
client->SendMessage(lmessage);
1028+
} catch (const std::runtime_error& ex) {
1029+
Log(LogInformation, "ApiListener")
1030+
<< "Error while setting log position for identity '" << endpoint->GetName() << "': " << DiagnosticInformation(ex, false);
1031+
}
10271032
} else {
10281033
client->Disconnect();
10291034
}
@@ -1195,7 +1200,12 @@ void ApiListener::SyncSendMessage(const Endpoint::Ptr& endpoint, const Dictionar
11951200
if (client->GetTimestamp() != maxTs)
11961201
continue;
11971202

1198-
client->SendMessage(message);
1203+
try {
1204+
client->SendMessage(message);
1205+
} catch (const std::runtime_error& ex) {
1206+
Log(LogInformation, "ApiListener")
1207+
<< "Error while sending message to endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex, false);
1208+
}
11991209
}
12001210
}
12011211
}

0 commit comments

Comments
 (0)