This is the code that I use to write the boost property tree structure into a file
void writeConfigurationFile(std::string filePath, boost::property_tree::ptree &configurationTree)
{
try
{
boost::property_tree::write_json(filePath, configurationTree);
}
catch (boost::property_tree::ptree_bad_path &e)
{
LOGGER_EXCEPTION(std::string("boost::property_tree::ptree_bad_path => what:").append(e.what()).c_str());
}
catch (boost::property_tree::ptree_error &e)
{
LOGGER_EXCEPTION(std::string("boost::property_tree::ptree_error => what:").append(e.what()).c_str());
}
catch (...)
{
LOGGER_EXCEPTION("Exception occurred in writing Configuration file");
}
}
I am getting an exception
LOGGER_EXCEPTION: boost::property_tree::ptree_error => what:configuration.json: cannot open file.
However I can see that the file is very much present there. Is there a reason why this would fail? Also are the exceptions that I am catching correct ?