Skip to content

Commit

Permalink
refactor: Update error message in Groot2Publisher constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
lpohsien committed May 21, 2024
1 parent f18e2ce commit 610dbc1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/loggers/groot2_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 610dbc1

Please sign in to comment.