All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AlgErrorAuditor.cpp
Go to the documentation of this file.
1 #include "AlgErrorAuditor.h"
5 
7 
8 void
9 AlgErrorAuditor:: beforeExecute(INamedInterface* ){
10  m_error = msgSvc()->messageCount(MSG::ERROR);
11  m_fatal = msgSvc()->messageCount(MSG::FATAL);
12 }
13 
16 
17  if (m_abort && m_throw) {
18  info() << "Both \"Throw\" and \"Abort\" options have been set."
19  << " Abort takes precedence." << endmsg;
20  }
21 
22  return StatusCode::SUCCESS;
23 }
24 
25 
26 void
28 
29  bool fail(false);
30  if (msgSvc()->messageCount(MSG::ERROR) != m_error && ! sc.isRecoverable() ) {
32  os << "Illegal Return Code: Algorithm " << alg->name()
33  << " reported an ERROR, but returned a StatusCode \"" << sc << "\"";
34  os << std::endl << "Error policy described in "
35  << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
36 
37  error() << os.str() << endmsg;
38  incrMap(alg->name(), 0);
39  fail = true;
40 
41  if (m_throw && ! m_abort) {
42  throw GaudiException(os.str(),"AlgErrorAuditor",0);
43  }
44  }
45 
47  sc != StatusCode::FAILURE ) {
49  os << "Illegal Return Code: Algorithm " << alg->name()
50  << " reported a FATAL, but returned a StatusCode \"" << sc << "\"";
51  os << std::endl << "Error policy described in "
52  << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
53 
54  error() << os.str() << endmsg;
55  incrMap(alg->name(), 1);
56  fail = true;
57 
58  if (m_throw && ! m_abort) {
59  throw GaudiException(os.str(),"AlgErrorAuditor",0);
60  }
61 
62  }
63 
64  if (fail && m_abort) {
65  abort();
66  }
67 
68 }
69 
72 
73  if (m_algMap[0].size() != 0) {
74  info() << "Found " << m_algMap[0].size()
75  << " instances where an Algorithm::execute() produced an ERROR "
76  << "but returned a SUCCESS:" << std::endl;
77 
78  for (const auto& i : m_algMap[0] ) {
79  msgStream() << i.first << ": " << i.second << std::endl;
80  }
81 
82  msgStream() << endmsg;
83  }
84 
85  if (m_algMap[1].size() != 0) {
86  info() << "Found " << m_algMap[1].size()
87  << " instances where an Algorithm::execute() produced a FATAL "
88  << "but returned a SUCCESS:" << std::endl;
89 
90  for (const auto& i : m_algMap[1]) {
91  msgStream() << i.first << ": " << i.second << std::endl;
92  }
93 
94  msgStream() << endmsg;
95  }
96  return StatusCode::SUCCESS;
97 }
98 
99 void
101  auto i=m_algMap[level].find(alg);
102  if ( i != m_algMap[level].end()) {
103  i->second++;
104  } else {
105  m_algMap[level].emplace( alg,1 );
106  }
107 }
StatusCode finalize() override
Define general base for Gaudi exception.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
std::map< std::string, int > m_algMap[2]
Monitors the cpu time usage of each algorithm.
virtual int messageCount(MSG::Level level) const =0
Get the number of messages issued at a particular level.
T endl(T...args)
class MergingTransformer< Out(const vector_of_const_< In > void
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
void incrMap(const std::string &algName, int level)
void afterExecute(INamedInterface *alg, const StatusCode &) override
StatusCode initialize() override
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
bool isRecoverable() const
Definition: StatusCode.h:85
Gaudi::Property< bool > m_abort
Gaudi::Property< bool > m_throw
IInterface compliant class extending IInterface with the name() method.
T find(T...args)
T size(T...args)
T emplace(T...args)
MsgStream & msgStream() const
Return an uninitialized MsgStream.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual const std::string & name() const =0
Retrieve the name of the instance.