Skip to content

Commit

Permalink
Refactor DDS CommonParticipant to handle InitializationException in c…
Browse files Browse the repository at this point in the history
…reate_writer and create_reader
  • Loading branch information
irenebm committed Sep 2, 2024
1 parent c43a6f7 commit c09780e
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,20 @@ std::shared_ptr<core::IWriter> CommonParticipant::create_writer(
return std::make_shared<BlankWriter>();
}

// Get the DDS Topic associated (create it if it does not exist)
fastdds::dds::Topic* fastdds_topic = topic_related_(dds_topic);
fastdds::dds::Topic* fastdds_topic;
try
{
// Get the DDS Topic associated (create it if it does not exist)
fastdds_topic = topic_related_(dds_topic);
}
catch (const utils::InitializationException& e)
{
EPROSIMA_LOG_WARNING(
DDSPIPE_DDS_PARTICIPANT,
e.what()
<< " Execution continue but this topic will not be published in Participant " << id() << ".");
return std::make_shared<BlankWriter>();
}

if (dds_topic.topic_qos.has_partitions() || dds_topic.topic_qos.has_ownership())
{
Expand Down Expand Up @@ -303,7 +315,20 @@ std::shared_ptr<core::IReader> CommonParticipant::create_reader(
}

// Get the DDS Topic associated (create it if it does not exist)
fastdds::dds::Topic* fastdds_topic = topic_related_(dds_topic);
fastdds::dds::Topic* fastdds_topic;
try
{
// Get the DDS Topic associated (create it if it does not exist)
fastdds_topic = topic_related_(dds_topic);
}
catch (const utils::InitializationException& e)
{
EPROSIMA_LOG_WARNING(
DDSPIPE_DDS_PARTICIPANT,
e.what()
<< ". Execution continue but this topic will not be subscribed in Participant " << id() << ".");
return std::make_shared<BlankReader>();
}

if (dds_topic.topic_qos.has_partitions() || dds_topic.topic_qos.has_ownership())
{
Expand Down

0 comments on commit c09780e

Please sign in to comment.