Skip to content

Commit e9f46cc

Browse files
committed
Improve exception message from GenParticleProducer
1 parent a26fcac commit e9f46cc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

PhysicsTools/HepMCCandAlgos/plugins/GenParticleProducer.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,14 @@ void GenParticleProducer::produce(StreamID, Event& evt, const EventSetup& es) co
235235
} else {
236236
Handle<HepMC3Product> mcp3;
237237
bool found = evt.getByToken(srcToken3_, mcp3);
238-
if (!found)
239-
throw cms::Exception("ProductAbsent") << "No HepMCProduct, tried to get HepMC3Product, but it is also absent.";
238+
if (!found) {
239+
try {
240+
*mcp3;
241+
} catch (cms::Exception& iExcept) {
242+
iExcept.addContext("No HepMCProduct, tried to get HepMC3Product, but it is also absent.");
243+
throw;
244+
}
245+
}
240246
ivhepmc = 3;
241247
mc3 = new HepMC3::GenEvent();
242248
mc3->read_data(*mcp3->GetEvent());

0 commit comments

Comments
 (0)