Output rcl error message when yaml parsing fails (#557)

This commit is contained in:
dhood 2018-09-13 17:46:56 -07:00 committed by GitHub
parent 80595f37d1
commit 86cc8fdb3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,6 +18,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <sstream>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -120,7 +121,11 @@ NodeParameters::NodeParameters(
throw std::bad_alloc(); throw std::bad_alloc();
} }
if (!rcl_parse_yaml_file(yaml_path.c_str(), yaml_params)) { if (!rcl_parse_yaml_file(yaml_path.c_str(), yaml_params)) {
throw std::runtime_error("Failed to parse parameters " + yaml_path); std::ostringstream ss;
ss << "Failed to parse parameters from file '" << yaml_path << "': " <<
rcl_get_error_string_safe();
rcl_reset_error();
throw std::runtime_error(ss.str());
} }
rclcpp::ParameterMap initial_map = rclcpp::parameter_map_from(yaml_params); rclcpp::ParameterMap initial_map = rclcpp::parameter_map_from(yaml_params);