Skip to content

Commit

Permalink
Adding in topic name to logging on IPC issues (#2706) (#2709)
Browse files Browse the repository at this point in the history
* Adding in topic name to logging on IPC issues

Signed-off-by: Steve Macenski <[email protected]>

* Update test matching output logging

Signed-off-by: Steve Macenski <[email protected]>

* adding in single quotes

Signed-off-by: Steve Macenski <[email protected]>

---------

Signed-off-by: Steve Macenski <[email protected]>
(cherry picked from commit a13e16e)

Co-authored-by: Steve Macenski <[email protected]>
  • Loading branch information
mergify[bot] and SteveMacenski authored Dec 14, 2024
1 parent e9edc3f commit 1a353f0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions rclcpp/include/rclcpp/publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ class Publisher : public PublisherBase
const rclcpp::PublisherOptionsWithAllocator<AllocatorT> & options)
{
// Topic is unused for now.
(void)topic;
(void)options;

// If needed, setup intra process communication.
Expand All @@ -189,11 +188,13 @@ class Publisher : public PublisherBase
// Register the publisher with the intra process manager.
if (qos.history() != rclcpp::HistoryPolicy::KeepLast) {
throw std::invalid_argument(
"intraprocess communication allowed only with keep last history qos policy");
"intraprocess communication on topic '" + topic +
"' allowed only with keep last history qos policy");
}
if (qos.depth() == 0) {
throw std::invalid_argument(
"intraprocess communication is not allowed with a zero qos history depth value");
"intraprocess communication on topic '" + topic +
"' is not allowed with a zero qos history depth value");
}
if (qos.durability() != rclcpp::DurabilityPolicy::Volatile) {
throw std::invalid_argument(
Expand Down
6 changes: 4 additions & 2 deletions rclcpp/include/rclcpp/subscription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ class Subscription : public SubscriptionBase
auto qos_profile = get_actual_qos();
if (qos_profile.history() != rclcpp::HistoryPolicy::KeepLast) {
throw std::invalid_argument(
"intraprocess communication allowed only with keep last history qos policy");
"intraprocess communication on topic '" + topic_name +
"' allowed only with keep last history qos policy");
}
if (qos_profile.depth() == 0) {
throw std::invalid_argument(
"intraprocess communication is not allowed with 0 depth qos policy");
"intraprocess communication on topic '" + topic_name +
"' is not allowed with 0 depth qos policy");
}
if (qos_profile.durability() != rclcpp::DurabilityPolicy::Volatile) {
throw std::invalid_argument(
Expand Down
3 changes: 2 additions & 1 deletion rclcpp/test/rclcpp/test_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ TEST_F(TestPublisher, intra_process_publish_failures) {
node->create_publisher<test_msgs::msg::Empty>(
"topic", rclcpp::QoS(0), options),
std::invalid_argument(
"intraprocess communication is not allowed with a zero qos history depth value"));
"intraprocess communication on topic 'topic' "
"is not allowed with a zero qos history depth value"));
}

TEST_F(TestPublisher, inter_process_publish_failures) {
Expand Down

0 comments on commit 1a353f0

Please sign in to comment.