Skip to content

Commit

Permalink
Make PodioOutput exit gracefully instead of crashing (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener authored Nov 15, 2023
1 parent bba5dc2 commit 7c2dbe8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion k4FWCore/components/PodioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,25 @@ StatusCode PodioOutput::execute() {
}
m_framewriter->writeFrame(frame, "events", m_collection_names_to_write);
} else {
m_framewriter->writeFrame(frame, "events", m_collection_names_to_write);
try {
m_framewriter->writeFrame(frame, "events", m_collection_names_to_write);
} catch (std::runtime_error&) {
// In this error message we are only interested in the ones that are
// missing, since only a missing collection can trigger the exception
// here. Additional collections that are present in the Frame are not
// necessarily an issue here, because we might just be configured to not
// write all of them
const auto& [missing, _] = m_framewriter->checkConsistency(frame.getAvailableCollections(), "events");
error() << "Could not write event, because the following collections are not present: ";
std::string sep = "";
for (const auto& name : missing) {
error() << sep << name;
sep = ", ";
}
error() << endmsg;

return StatusCode::FAILURE;
}
}
m_firstEvent = false;

Expand Down

0 comments on commit 7c2dbe8

Please sign in to comment.