From 00284b782758d9ab91b0c6c4bf72efe626c83871 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Thu, 28 Nov 2013 15:00:15 +0000 Subject: [PATCH] - added excpetion handler to get printout of error message when exception is not caught ... ( also creates ROOT seg fault and stack trace which might be useful for debugging - don't call exit(1) to avoid seg fault in lcdd_unexpected() ) --- DDCore/src/LCDDImp.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/DDCore/src/LCDDImp.cpp b/DDCore/src/LCDDImp.cpp index 718e458ea..423688eda 100644 --- a/DDCore/src/LCDDImp.cpp +++ b/DDCore/src/LCDDImp.cpp @@ -69,6 +69,25 @@ namespace { static LCDD* s_lcdd = 0; } +void lcdd_unexpected(){ + try{ + throw ; + }catch( std::exception& e){ + std::cout << "\n" + << "**************************************************** \n" + << "* A runtime error has occured : \n" + << "* " << e.what() << std::endl + << "* the program will have to be terminated - sorry. \n" + << "**************************************************** \n" + << std::endl ; + + // this provokes ROOT seg fault and stack trace (comment out to avoid it) + exit(1) ; + } +} + + + LCDD& LCDD::getInstance() { if (!s_lcdd) s_lcdd = new LCDDImp(); @@ -85,7 +104,11 @@ void LCDD::destroyInstance() { /// Default constructor LCDDImp::LCDDImp() : m_world(), m_trackers(), m_worldVol(), m_trackingVol(), m_field("global"), m_buildType(BUILD_NONE) { - InstanceCount::increment(this); + + std::set_unexpected( lcdd_unexpected ) ; + std::set_terminate( lcdd_unexpected ) ; + + InstanceCount::increment(this); m_properties = new Properties(); if (0 == gGeoManager) { gGeoManager = new TGeoManager(); -- GitLab