Skip to content

Commit

Permalink
only append search paths on first PackageNotFound (#91)
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Walter <[email protected]>
  • Loading branch information
lucasw authored Mar 25, 2024
1 parent fbccc98 commit 327a38f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ament_index_cpp/src/get_package_prefix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@
namespace ament_index_cpp
{

static size_t package_not_found_count = 0;

static
std::string
format_package_not_found_error_message(const std::string & package_name)
{
std::string message = "package '" + package_name + "' not found, searching: [";
std::string message = "package '" + package_name + "' not found";

// Don't need to print out the package paths more than once
if (package_not_found_count++ > 0) {
return message;
}

message += ", searching: [";
auto search_paths = get_search_paths();
for (const auto & path : search_paths) {
message += path + ", ";
Expand Down

0 comments on commit 327a38f

Please sign in to comment.