diff --git a/include/core/utils/params_server.hpp b/include/core/utils/params_server.hpp index c8d74c4df793b8f16696a5674150af505651e7bd..20ade7d5d768078531954e93837b48c9a132ce2f 100644 --- a/include/core/utils/params_server.hpp +++ b/include/core/utils/params_server.hpp @@ -82,7 +82,7 @@ public: if(_params.find(key) != _params.end()){ return converter<T>::convert(_params.find(key)->second); }else{ - throw std::runtime_error("The following key: '" + key + "' has not been found in the parameters server and no default value was provided."); + throw std::runtime_error("The following key: '" + key + "' has not been found in the parameters server."); } } diff --git a/include/core/yaml/parser_yaml.hpp b/include/core/yaml/parser_yaml.hpp index bb80d19529198891b1ea0ea8e6c740144788c161..0569abc11b3e4216ab3e20bc1bf84e9dc17a11be 100644 --- a/include/core/yaml/parser_yaml.hpp +++ b/include/core/yaml/parser_yaml.hpp @@ -7,6 +7,7 @@ #include "yaml-cpp/yaml.h" #include <vector> +#include <stack> #include <regex> #include <map> #include <iostream> @@ -180,6 +181,7 @@ class ParserYAML { std::vector<ParamsInitSensor> _paramsSens; std::vector<ParamsInitProcessor> _paramsProc; std::vector<std::string> _files; + std::stack<std::string> _parsing_file; std::string _file; bool _relative_path; std::string _path_root; @@ -195,6 +197,7 @@ public: _paramsProc = std::vector<ParamsInitProcessor>(); _file = ""; _files = std::vector<std::string>(); + _parsing_file = std::stack<std::string>(); _path_root = ""; _relative_path = false; _callbacks = std::vector<std::array<std::string, 3>>(); @@ -205,6 +208,7 @@ public: _paramsSens = std::vector<ParamsInitSensor>(); _paramsProc = std::vector<ParamsInitProcessor>(); _files = std::vector<std::string>(); + _parsing_file = std::stack<std::string>(); _file = file; _path_root = ""; _relative_path = false; @@ -216,6 +220,7 @@ public: _paramsSens = std::vector<ParamsInitSensor>(); _paramsProc = std::vector<ParamsInitProcessor>(); _files = std::vector<std::string>(); + _parsing_file = std::stack<std::string>(); _file = file; if(path_root != ""){ std::regex r("/$"); @@ -255,9 +260,11 @@ std::string ParserYAML::generatePath(std::string path){ } YAML::Node ParserYAML::loadYAML(std::string file){ try{ + // std::cout << "Parsing " << generatePath(file) << std::endl; + WOLF_INFO("Parsing file: ", generatePath(file)); return YAML::LoadFile(generatePath(file)); }catch (YAML::BadFile& e){ - throw std::runtime_error("Couldn't load file " + generatePath(file)); + throw std::runtime_error("Couldn't load file " + generatePath(file) + ". Tried to open it from " + this->_parsing_file.top()); } } std::string ParserYAML::tagsToString(std::vector<std::string> &tags){ @@ -269,22 +276,25 @@ std::string ParserYAML::tagsToString(std::vector<std::string> &tags){ } void ParserYAML::walkTree(std::string file){ YAML::Node n; - std::cout << "Parsing " << generatePath(file) << std::endl; n = loadYAML(generatePath(file)); + this->_parsing_file.push(generatePath(file)); std::vector<std::string> hdrs = std::vector<std::string>(); walkTreeR(n, hdrs, ""); + this->_parsing_file.pop(); } void ParserYAML::walkTree(std::string file, std::vector<std::string>& tags){ YAML::Node n; - std::cout << "Parsing " << generatePath(file) << std::endl; n = loadYAML(generatePath(file)); + this->_parsing_file.push(generatePath(file)); walkTreeR(n, tags, ""); + this->_parsing_file.pop(); } void ParserYAML::walkTree(std::string file, std::vector<std::string>& tags, std::string hdr){ YAML::Node n; - std::cout << "Parsing " << generatePath(file) << std::endl; n = loadYAML(generatePath(file)); + this->_parsing_file.push(generatePath(file)); walkTreeR(n, tags, hdr); + this->_parsing_file.pop(); } /** @Brief Recursively walks the YAML tree while filling a map with the values parsed from the file * @param YAML node to be parsed @@ -372,7 +382,6 @@ void ParserYAML::updateActiveName(std::string tag){ * @param file is the path to the YAML file */ void ParserYAML::parseFirstLevel(std::string file){ YAML::Node n; - std::cout << "Parsing " << generatePath(file) << std::endl; n = loadYAML(generatePath(file)); YAML::Node n_config = n["config"]; @@ -431,6 +440,7 @@ std::map<std::string,std::string> ParserYAML::getParams(){ return rtn; } void ParserYAML::parse(){ + this->_parsing_file.push(generatePath(this->_file)); this->parseFirstLevel(this->_file); if(this->problem.Type() != YAML::NodeType::Undefined){ @@ -445,5 +455,6 @@ void ParserYAML::parse(){ std::vector<std::string> tags = std::vector<std::string>(); this->walkTreeR(it.n , tags , it._name); } + this->_parsing_file.pop(); } #endif