lordgamez commented on a change in pull request #1220:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1220#discussion_r764774883
##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -529,14 +529,20 @@ void YamlConfiguration::parseControllerServices(const
YAML::Node& controllerServ
CONFIG_YAML_CONTROLLER_SERVICES_KEY);
std::string type = "";
- try {
- yaml::checkRequiredField(&controllerServiceNode, "class", logger_,
CONFIG_YAML_CONTROLLER_SERVICES_KEY);
+ if (yaml::isFieldPresent(&controllerServiceNode, "class")) {
type = controllerServiceNode["class"].as<std::string>();
- } catch (const std::invalid_argument &) {
- yaml::checkRequiredField(&controllerServiceNode, "type", logger_,
CONFIG_YAML_CONTROLLER_SERVICES_KEY);
+ } else {
+ const YAML::Node name_node =
controllerServiceNode.as<YAML::Node>()["name"];
+ std::string err_msg =
+ name_node ?
+ "Unable to parse configuration file for component named '" +
name_node.as<std::string>() + "' as required field 'class' or 'type' is
missing" :
+ "Unable to parse configuration file as required field 'class' or
'type' is missing";
+ err_msg += " [in '" + std::string(CONFIG_YAML_CONTROLLER_SERVICES_KEY)
+ "' section of configuration file]";
+ yaml::checkRequiredField(&controllerServiceNode, "type", logger_,
CONFIG_YAML_CONTROLLER_SERVICES_KEY, err_msg);
Review comment:
Good idea, added in 31e4679c2f41a3f2a788132ca34a77fedf5d9ec7
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]