From a256c12253b52d95d43185464bdbfd46eab28a53 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 7 Feb 2024 10:29:10 -0600 Subject: [PATCH] Better context for exception during reading of ParameterSets --- IOPool/Input/src/RootFile.cc | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/IOPool/Input/src/RootFile.cc b/IOPool/Input/src/RootFile.cc index f0242b9721cf2..2e90fef497cc6 100644 --- a/IOPool/Input/src/RootFile.cc +++ b/IOPool/Input/src/RootFile.cc @@ -414,12 +414,23 @@ namespace edm { } else { // Merge into the parameter set registry. pset::Registry& psetRegistry = *pset::Registry::instance(); - for (auto const& psetEntry : psetMap) { - ParameterSet pset(psetEntry.second.pset()); - pset.setID(psetEntry.first); - // For thread safety, don't update global registries when a secondary source opens a file. - if (inputType != InputType::SecondarySource) { - psetRegistry.insertMapped(pset); + try { + for (auto const& psetEntry : psetMap) { + ParameterSet pset(psetEntry.second.pset()); + pset.setID(psetEntry.first); + // For thread safety, don't update global registries when a secondary source opens a file. + if (inputType != InputType::SecondarySource) { + psetRegistry.insertMapped(pset); + } + } + } catch (edm::Exception const& iExcept) { + if (iExcept.categoryCode() == edm::errors::Configuration) { + edm::Exception exception(edm::errors::FormatIncompatibility); + exception << iExcept.message(); + exception.addContext("Creating ParameterSets from file"); + throw exception; + } else { + throw; } } }