Skip to content

Commit 28933e2

Browse files
justonedev1Michal Tichák
andauthored
QC-1213 A QCDB restart must not stop the run (#2512)
* [Framework] try catch around read_json in CcdbDatabase.cxx * fixup! [Framework] try catch around read_json in CcdbDatabase.cxx --------- Co-authored-by: Michal Tichák <michal.tichak@cern.ch>
1 parent be312ed commit 28933e2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Framework/src/CcdbDatabase.cxx

Lines changed: 12 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,11 @@ 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+
ILOG(Error, Support) << "Failed to parse json in CcdbDatabase::getListingAsPtree from data: " << listingAsStringStream.str() << ENDM;
575+
}
572576

573577
return listingAsTree;
574578
}
@@ -616,7 +620,12 @@ std::vector<std::string> CcdbDatabase::getPublishedObjectNames(std::string taskN
616620
boost::property_tree::ptree pt;
617621
stringstream ss;
618622
ss << listing;
619-
boost::property_tree::read_json(ss, pt);
623+
624+
try {
625+
boost::property_tree::read_json(ss, pt);
626+
} catch (const boost::property_tree::json_parser::json_parser_error&) {
627+
ILOG(Error, Support) << "Failed to parse json in CcdbDatabase::getTimestampsForObject from data: " << ss.str() << ENDM;
628+
}
620629

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

0 commit comments

Comments
 (0)