From 7822e3dfcac1e4f37fbf6a59790f9c7fba1c86d2 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Thu, 9 Nov 2023 11:57:45 +0100 Subject: [PATCH] Use new functionality to give a more precise error --- k4FWCore/components/PodioOutput.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/k4FWCore/components/PodioOutput.cpp b/k4FWCore/components/PodioOutput.cpp index 3a343f12..d7573ee2 100644 --- a/k4FWCore/components/PodioOutput.cpp +++ b/k4FWCore/components/PodioOutput.cpp @@ -59,8 +59,21 @@ StatusCode PodioOutput::execute() { } else { try { m_framewriter->writeFrame(frame, "events", m_collection_names_to_write); - } catch (std::runtime_error& e) { - error() << "Could not write event: " << e.what() << endmsg; + } 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& n : missing) { + error() << sep << n; + sep = ", "; + } + error() << endmsg; + return StatusCode::FAILURE; } }