The Gaudi Framework  v30r3 (a5ef0a68)
AlgErrorAuditor.cpp
Go to the documentation of this file.
1 #include "AlgErrorAuditor.h"
5 
7 
9 {
10  m_error = msgSvc()->messageCount( MSG::ERROR );
11  m_fatal = msgSvc()->messageCount( MSG::FATAL );
12 }
13 
15 {
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 
26 {
27 
28  bool fail( false );
29  if ( msgSvc()->messageCount( MSG::ERROR ) != m_error && !sc.isRecoverable() ) {
31  os << "Illegal Return Code: Algorithm " << alg->name() << " reported an ERROR, but returned a StatusCode \"" << sc
32  << "\"";
33  os << std::endl
34  << "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", StatusCode::FAILURE );
43  }
44  }
45 
46  if ( msgSvc()->messageCount( MSG::FATAL ) != m_fatal && sc != StatusCode::FAILURE ) {
48  os << "Illegal Return Code: Algorithm " << alg->name() << " reported a FATAL, but returned a StatusCode \"" << sc
49  << "\"";
50  os << std::endl
51  << "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", StatusCode::FAILURE );
60  }
61  }
62 
63  if ( fail && m_abort ) {
64  abort();
65  }
66 }
67 
69 {
70 
71  if ( m_algMap[0].size() != 0 ) {
72  info() << "Found " << m_algMap[0].size() << " instances where an Algorithm::execute() produced an ERROR "
73  << "but returned a SUCCESS:" << std::endl;
74 
75  for ( const auto& i : m_algMap[0] ) {
76  msgStream() << i.first << ": " << i.second << std::endl;
77  }
78 
79  msgStream() << endmsg;
80  }
81 
82  if ( m_algMap[1].size() != 0 ) {
83  info() << "Found " << m_algMap[1].size() << " instances where an Algorithm::execute() produced a FATAL "
84  << "but returned a SUCCESS:" << std::endl;
85 
86  for ( const auto& i : m_algMap[1] ) {
87  msgStream() << i.first << ": " << i.second << std::endl;
88  }
89 
90  msgStream() << endmsg;
91  }
92  return StatusCode::SUCCESS;
93 }
94 
96 {
97  auto i = m_algMap[level].find( alg );
98  if ( i != m_algMap[level].end() ) {
99  i->second++;
100  } else {
101  m_algMap[level].emplace( alg, 1 );
102  }
103 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
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
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
STL class.
#define DECLARE_COMPONENT(type)
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:51
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isRecoverable() const
Definition: StatusCode.h:293
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
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.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
virtual const std::string & name() const =0
Retrieve the name of the instance.