Skip to content

Commit

Permalink
Catch and rethrow xml exceptions in TotemDAQMappingESSourceXML
Browse files Browse the repository at this point in the history
The exceptions are converted to cms::Exceptions.
  • Loading branch information
Dr15Jones committed Apr 12, 2023
1 parent b0b0e73 commit 0069f22
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ string TotemDAQMappingESSourceXML::CompleteFileName(const string &fn) {
}

//----------------------------------------------------------------------------------------------------
static inline std::string to_string(const XMLCh *ch) { return XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(ch); }

edm::ESProducts<std::unique_ptr<TotemDAQMapping>, std::unique_ptr<TotemAnalysisMask>>
TotemDAQMappingESSourceXML::produce(const TotemReadoutRcd &) {
Expand All @@ -347,19 +348,26 @@ TotemDAQMappingESSourceXML::produce(const TotemReadoutRcd &) {
auto mapping = std::make_unique<TotemDAQMapping>();
auto mask = std::make_unique<TotemAnalysisMask>();

// initialize Xerces
cms::concurrency::xercesInitialize();

// load mapping files
for (const auto &fn : configuration[currentBlock].mappingFileNames)
ParseXML(pMapping, CompleteFileName(fn), mapping, mask);

// load mask files
for (const auto &fn : configuration[currentBlock].maskFileNames)
ParseXML(pMask, CompleteFileName(fn), mapping, mask);

// release Xerces
cms::concurrency::xercesTerminate();
try {
// initialize Xerces
cms::concurrency::xercesInitialize();

// load mapping files
for (const auto &fn : configuration[currentBlock].mappingFileNames)
ParseXML(pMapping, CompleteFileName(fn), mapping, mask);

// load mask files
for (const auto &fn : configuration[currentBlock].maskFileNames)
ParseXML(pMask, CompleteFileName(fn), mapping, mask);

// release Xerces
cms::concurrency::xercesTerminate();
} catch (const XMLException &e) {
throw cms::Exception("XMLDocument") << "cms::concurrency::xercesInitialize failed because of "
<< to_string(e.getMessage()) << std::endl;
} catch (const SAXException &e) {
throw cms::Exception("XMLDocument") << "XML parser reported: " << to_string(e.getMessage()) << "." << std::endl;
}

// commit the products
return edm::es::products(std::move(mapping), std::move(mask));
Expand Down

0 comments on commit 0069f22

Please sign in to comment.