Skip to content

Commit e0a7971

Browse files
author
Michal Tichák
committed
[Framework] try catch around read_json in CcdbDatabase.cxx
1 parent be312ed commit e0a7971

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Framework/src/CcdbDatabase.cxx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
#include <chrono>
3838
#include <sstream>
3939
#include <filesystem>
40-
#include <unordered_set>
4140
// boost
4241
#include <boost/property_tree/json_parser.hpp>
42+
#include <boost/property_tree/json_parser/error.hpp>
4343
#include <boost/property_tree/ptree.hpp>
4444
#include <boost/foreach.hpp>
4545
#include <utility>
@@ -568,7 +568,10 @@ boost::property_tree::ptree CcdbDatabase::getListingAsPtree(const std::string& p
568568
std::stringstream listingAsStringStream{ getListingAsString(pathWithMetadata.str(), "application/json", latestOnly) };
569569

570570
boost::property_tree::ptree listingAsTree;
571-
boost::property_tree::read_json(listingAsStringStream, listingAsTree);
571+
try {
572+
boost::property_tree::read_json(listingAsStringStream, listingAsTree);
573+
} catch (const boost::property_tree::json_parser::json_parser_error&) {
574+
}
572575

573576
return listingAsTree;
574577
}
@@ -616,7 +619,11 @@ std::vector<std::string> CcdbDatabase::getPublishedObjectNames(std::string taskN
616619
boost::property_tree::ptree pt;
617620
stringstream ss;
618621
ss << listing;
619-
boost::property_tree::read_json(ss, pt);
622+
623+
try {
624+
boost::property_tree::read_json(ss, pt);
625+
} catch (const boost::property_tree::json_parser::json_parser_error&) {
626+
}
620627

621628
BOOST_FOREACH (boost::property_tree::ptree::value_type& v, pt.get_child("objects")) {
622629
assert(v.first.empty()); // array elements have no names

0 commit comments

Comments
 (0)