Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more error information when parsing virtual configs and treat emp… #8

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions config_utilities/include/config_utilities/factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ struct ModuleMapBase {
return false;
}
if (map.find(type) == map.end()) {
std::string module_list;
for (const auto& entry : map) {
module_list.append(entry.first + "', '");
if (!type.empty()) {
std::string module_list;
for (const auto& entry : map) {
module_list.append(entry.first + "', '");
}
module_list = module_list.substr(0, module_list.size() - 4);
Logger::logError("No module of type '" + type + "' registered to the factory for " + type_info +
". Registered are: '" + module_list + "'.");
}
module_list = module_list.substr(0, module_list.size() - 4);
Logger::logError("No module of type '" + type + "' registered to the factory for " + type_info +
". Registered are: '" + module_list + "'.");
return false;
}
return true;
Expand Down
6 changes: 6 additions & 0 deletions config_utilities/include/config_utilities/virtual_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class VirtualConfig {
*/
void setOptional(bool optional = true) { optional_ = optional; }

bool optional() const { return optional_; }

/**
* @brief Get the string-identifier-type of the config stored in the virtual config.
*/
Expand Down Expand Up @@ -166,6 +168,10 @@ void declare_config(VirtualConfig<BaseT>& config) {
: internal::getType(*data, type);
if (success) {
config.config_ = internal::ConfigFactory<BaseT>::create(type);
} else if (!config.optional_) {
std::stringstream ss;
ss << "Could not get type for '" << internal::typeInfo<BaseT>() << "'";
internal::Logger::logError(ss.str());
}
}

Expand Down