From 610dbc158b4a53363c793c96cbccad18d4b11631 Mon Sep 17 00:00:00 2001 From: lpohsien Date: Tue, 21 May 2024 06:47:14 +0000 Subject: [PATCH] refactor: Update error message in Groot2Publisher constructor --- src/loggers/groot2_publisher.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/loggers/groot2_publisher.cpp b/src/loggers/groot2_publisher.cpp index 6146507e8..cb50449f1 100644 --- a/src/loggers/groot2_publisher.cpp +++ b/src/loggers/groot2_publisher.cpp @@ -114,8 +114,17 @@ Groot2Publisher::Groot2Publisher(const BT::Tree& tree, unsigned server_port) if(Groot2Publisher::used_ports.count(server_port) != 0 || Groot2Publisher::used_ports.count(server_port + 1) != 0) { - auto msg = StrCat("Another instance of Groot2Publisher is using port ", - std::to_string(server_port)); + // Modified: Since both server_port and server_port+1 are used by the + // same server, error message should be updated to reflect this. + auto msg = "Another instance of Groot2Publisher is using port " + + std::to_string(server_port) + " or " + std::to_string(server_port + 1); + + msg += ". Used ports:"; + for (auto port : Groot2Publisher::used_ports) + { + msg += " " + std::to_string(port); + } + throw LogicError(msg); } Groot2Publisher::used_ports.insert(server_port);