Skip to content

Commit

Permalink
SKA-485: remove the publish when an error occurs in advalues mode (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
VKyllianAubry authored and GitHub Enterprise committed Apr 24, 2024
1 parent c5ffe85 commit 6227032
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion advalues/adapter/AdAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ auto AdAdapter::Serialize() -> std::vector<uint8_t>
}

_logger->Debug("Serializing data and publishing on topic: " + _publishTopic);

return serializer.ReleaseBuffer();
}
catch (const std::out_of_range& e)
{
Expand All @@ -108,7 +110,7 @@ auto AdAdapter::Serialize() -> std::vector<uint8_t>
_logger->Error("Something went wrong when trying to serialize data on " + _publishTopic + ": " + e.what());
}

return serializer.ReleaseBuffer();
return std::vector<uint8_t>{};
}

// Deserialize received values
Expand Down
5 changes: 4 additions & 1 deletion chardev/adapter/ChardevAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ void ChardevAdapter::Publish()
{
if (!_publishTopic.empty())
{
_publisher->Publish(Serialize());
if (const auto& bytes = Serialize(); !bytes.empty())
{
_publisher->Publish(bytes);
}
}
}

Expand Down

0 comments on commit 6227032

Please sign in to comment.