Incorrect error message when unable to snap all input coordinates (#5846)
In cases where we are unable to find a phantom node for an input coordinate, we return an error indicating which coordinate failed. This would always refer to the coordinate with index equal to the number of valid phantom nodes found. We fix this by instead returning the first index for which a phantom node could not be found.
This commit is contained in:
@@ -371,6 +371,22 @@ class BasePlugin
|
||||
}
|
||||
return phantom_node_pairs;
|
||||
}
|
||||
|
||||
std::string MissingPhantomErrorMessage(const std::vector<PhantomNodePair> &phantom_nodes,
|
||||
const std::vector<util::Coordinate> &coordinates) const
|
||||
{
|
||||
BOOST_ASSERT(phantom_nodes.size() < coordinates.size());
|
||||
auto mismatch = std::mismatch(phantom_nodes.begin(),
|
||||
phantom_nodes.end(),
|
||||
coordinates.begin(),
|
||||
coordinates.end(),
|
||||
[](const auto &phantom_node, const auto &coordinate) {
|
||||
return phantom_node.first.input_location == coordinate;
|
||||
});
|
||||
std::size_t missing_index = std::distance(phantom_nodes.begin(), mismatch.first);
|
||||
return std::string("Could not find a matching segment for coordinate ") +
|
||||
std::to_string(missing_index);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user