Skip to content

Commit 88fa08e

Browse files
committed
log error message if param type is unexpected
1 parent 8d588f3 commit 88fa08e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

mqtt_client/include/mqtt_client/MqttClient.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,12 @@ template <typename T>
455455
bool MqttClient::loadParameter(const std::string& key, T& value,
456456
const T& default_value) {
457457
bool found = private_node_handle_.param<T>(key, value, default_value);
458-
if (!found)
458+
if (!found) {
459+
if (private_node_handle_.hasParam(key))
460+
NODELET_ERROR("Parameter '%s' has wrong data type", key.c_str());
459461
NODELET_WARN("Parameter '%s' not set, defaulting to '%s'", key.c_str(),
460462
std::to_string(default_value).c_str());
463+
}
461464
if (found)
462465
NODELET_DEBUG("Retrieved parameter '%s' = '%s'", key.c_str(),
463466
std::to_string(value).c_str());

mqtt_client/src/MqttClient.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,12 @@ bool MqttClient::loadParameter(const std::string& key, std::string& value,
346346
const std::string& default_value) {
347347
bool found =
348348
private_node_handle_.param<std::string>(key, value, default_value);
349-
if (!found)
349+
if (!found) {
350+
if (private_node_handle_.hasParam(key))
351+
NODELET_ERROR("Parameter '%s' has wrong data type", key.c_str());
350352
NODELET_WARN("Parameter '%s' not set, defaulting to '%s'", key.c_str(),
351353
default_value.c_str());
354+
}
352355
if (found)
353356
NODELET_DEBUG("Retrieved parameter '%s' = '%s'", key.c_str(),
354357
value.c_str());

0 commit comments

Comments
 (0)