Skip to content

Commit

Permalink
only append search paths on first PackageNotFound
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Walter <wsacul@gmail.com>
  • Loading branch information
lucasw committed Dec 17, 2023
1 parent 076cef0 commit c9aac26
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ament_index_cpp/src/get_package_prefix.cpp
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 c9aac26

Please sign in to comment.