From da66481d7fdc04f3c97b363f4831921fb9090e73 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 7 Feb 2024 10:28:33 -0600 Subject: [PATCH 1/2] Changed assert to exception in Entry This assert was happening when an old release tried to read a file written by a newer release. --- FWCore/ParameterSet/src/Entry.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FWCore/ParameterSet/src/Entry.cc b/FWCore/ParameterSet/src/Entry.cc index 6092c44d6c5ea..83a82a612f29a 100644 --- a/FWCore/ParameterSet/src/Entry.cc +++ b/FWCore/ParameterSet/src/Entry.cc @@ -391,8 +391,9 @@ namespace edm { } default: { // We should never get here. - assert("Invalid type code" == nullptr); - //throw EntryError(std::string("invalid type code ") + type); + throw edm::Exception(edm::errors::Configuration) << "Unknown ParameterSet Entry type encoding: '" << type + << "'.\n This could be caused by reading a file which was " + "written using a newer incompatible software release."; break; } } // switch(type) From a256c12253b52d95d43185464bdbfd46eab28a53 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 7 Feb 2024 10:29:10 -0600 Subject: [PATCH 2/2] 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; } } }