ATLAS Offline Software
AthROOTErrorHandlerSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "TROOT.h"
8 
9 namespace Handler {
11  ErrorHandlerFunc_t oldHandler;
12 
13  void ErrorHandler ATLAS_NOT_THREAD_SAFE ( Int_t level, Bool_t abort, const char* location, const char* message ) {
14  if (svc) { // should always be set by now
15  if(svc->m_catchLevel <= level) {
16  std::ostringstream oss;
17  oss << "AthROOTErrorHandlerSvc detected ROOT message >= CatchLevel "
18  << svc->m_catchLevel << " (" << level << "): " << location << " : " << message;
19  throw std::runtime_error(oss.str());
20  }
21  const auto itr = svc->m_throwSources.find(location);
22  if(itr!=svc->m_throwSources.end() && itr->second <= level) {
23  std::ostringstream oss;
24  oss << "AthROOTErrorHandlerSvc detected ROOT message from Throw Sources : "
25  << location << " (level=" << level << ") : " << message;
26  throw std::runtime_error(oss.str());
27  }
28  }
29  //now pass on to old handler
30  if(oldHandler) oldHandler( level, abort, location, message );
31  }
32 
33 }
34 
35 
36 AthROOTErrorHandlerSvc::AthROOTErrorHandlerSvc(const std::string& name, ISvcLocator *svcLoc) :
37  AthService(name, svcLoc) {
38 }
39 
41 }
42 
43 
45 
46  ATH_MSG_DEBUG("Replacing ROOT ErrorHandler");
47  ErrorHandlerFunc_t h = ::SetErrorHandler( Handler::ErrorHandler );
48  Handler::svc = this;
49 
50  // if statement protects against double-initialize causing infinite loop in ErrorHandler
51  if (h != Handler::ErrorHandler) {
53  }
54  return StatusCode::SUCCESS;
55 }
56 
58 
59  ATH_MSG_DEBUG("Restoring old ROOT ErrorHandler");
60  Handler::svc = nullptr;
61  if (Handler::oldHandler) ::SetErrorHandler( Handler::oldHandler );
62  Handler::oldHandler = nullptr;
63  return StatusCode::SUCCESS;
64 }
AthROOTErrorHandlerSvc.h
Handler
AthROOTErrorHandlerSvc: Replaces ROOT's standard error handler in order to detect Problematic ROOT is...
Definition: AthROOTErrorHandlerSvc.cxx:9
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
ATLAS_NOT_THREAD_SAFE
StatusCode AthROOTErrorHandlerSvc::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: AthROOTErrorHandlerSvc.cxx:44
initialize
void initialize()
Definition: run_EoverP.cxx:894
AthROOTErrorHandlerSvc::AthROOTErrorHandlerSvc
AthROOTErrorHandlerSvc(const std::string &name, ISvcLocator *svcLoc)
Definition: AthROOTErrorHandlerSvc.cxx:36
AthROOTErrorHandlerSvc
Definition: AthROOTErrorHandlerSvc.h:42
Handler::oldHandler
ErrorHandlerFunc_t oldHandler
Definition: AthROOTErrorHandlerSvc.cxx:11
AthROOTErrorHandlerSvc::m_throwSources
Gaudi::Property< std::map< std::string, int > > m_throwSources
Definition: AthROOTErrorHandlerSvc.h:59
ReweightUtils.message
message
Definition: ReweightUtils.py:15
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
Handler::ATLAS_NOT_THREAD_SAFE
void ErrorHandler ATLAS_NOT_THREAD_SAFE(Int_t level, Bool_t abort, const char *location, const char *message)
Definition: AthROOTErrorHandlerSvc.cxx:13
AthROOTErrorHandlerSvc::~AthROOTErrorHandlerSvc
virtual ~AthROOTErrorHandlerSvc()
Definition: AthROOTErrorHandlerSvc.cxx:40
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
extractSporadic.h
list h
Definition: extractSporadic.py:97
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
python.sizes.location
string location
Definition: sizes.py:11
AthService
Definition: AthService.h:32
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
h
AthROOTErrorHandlerSvc::m_catchLevel
Gaudi::Property< int > m_catchLevel
Definition: AthROOTErrorHandlerSvc.h:55