From 57224dc024a471e2e6db8ae61778f319f490e713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Tich=C3=A1k?= Date: Mon, 24 Feb 2025 10:11:59 +0100 Subject: [PATCH] [Framework] try catch around read_json in CcdbDatabase.cxx --- Framework/src/CcdbDatabase.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Framework/src/CcdbDatabase.cxx b/Framework/src/CcdbDatabase.cxx index 3393f4ffc5..46bbe0636b 100644 --- a/Framework/src/CcdbDatabase.cxx +++ b/Framework/src/CcdbDatabase.cxx @@ -37,9 +37,9 @@ #include #include #include -#include // boost #include +#include #include #include #include @@ -568,7 +568,11 @@ boost::property_tree::ptree CcdbDatabase::getListingAsPtree(const std::string& p std::stringstream listingAsStringStream{ getListingAsString(pathWithMetadata.str(), "application/json", latestOnly) }; boost::property_tree::ptree listingAsTree; - boost::property_tree::read_json(listingAsStringStream, listingAsTree); + try { + boost::property_tree::read_json(listingAsStringStream, listingAsTree); + } catch (const boost::property_tree::json_parser::json_parser_error&) { + ILOG(Error, Support) << "Failed to parse json in CcdbDatabase::getListingAsPtree from data: " << listingAsStringStream.str() << ENDM; + } return listingAsTree; } @@ -616,7 +620,12 @@ std::vector CcdbDatabase::getPublishedObjectNames(std::string taskN boost::property_tree::ptree pt; stringstream ss; ss << listing; - boost::property_tree::read_json(ss, pt); + + try { + boost::property_tree::read_json(ss, pt); + } catch (const boost::property_tree::json_parser::json_parser_error&) { + ILOG(Error, Support) << "Failed to parse json in CcdbDatabase::getTimestampsForObject from data: " << ss.str() << ENDM; + } BOOST_FOREACH (boost::property_tree::ptree::value_type& v, pt.get_child("objects")) { assert(v.first.empty()); // array elements have no names