Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
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 AlgErrorAuditor::beforeExecute( INamedInterface* ) {
9  m_error = msgSvc()->messageCount( MSG::ERROR );
10  m_fatal = msgSvc()->messageCount( MSG::FATAL );
11 }
12 
14 
15  if ( m_abort && m_throw ) {
16  info() << "Both \"Throw\" and \"Abort\" options have been set."
17  << " Abort takes precedence." << endmsg;
18  }
19 
20  return StatusCode::SUCCESS;
21 }
22 
24 
25  bool fail( false );
26  if ( msgSvc()->messageCount( MSG::ERROR ) != m_error && !sc.isRecoverable() ) {
28  os << "Illegal Return Code: Algorithm " << alg->name() << " reported an ERROR, but returned a StatusCode \"" << sc
29  << "\"";
30  os << std::endl
31  << "Error policy described in "
32  << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
33 
34  error() << os.str() << endmsg;
35  incrMap( alg->name(), 0 );
36  fail = true;
37 
38  if ( m_throw && !m_abort ) { throw GaudiException( os.str(), "AlgErrorAuditor", StatusCode::FAILURE ); }
39  }
40 
41  if ( msgSvc()->messageCount( MSG::FATAL ) != m_fatal && sc != StatusCode::FAILURE ) {
43  os << "Illegal Return Code: Algorithm " << alg->name() << " reported a FATAL, but returned a StatusCode \"" << sc
44  << "\"";
45  os << std::endl
46  << "Error policy described in "
47  << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
48 
49  error() << os.str() << endmsg;
50  incrMap( alg->name(), 1 );
51  fail = true;
52 
53  if ( m_throw && !m_abort ) { throw GaudiException( os.str(), "AlgErrorAuditor", StatusCode::FAILURE ); }
54  }
55 
56  if ( fail && m_abort ) { abort(); }
57 }
58 
60 
61  if ( m_algMap[0].size() != 0 ) {
62  info() << "Found " << m_algMap[0].size() << " instances where an Algorithm::execute() produced an ERROR "
63  << "but returned a SUCCESS:" << std::endl;
64 
65  for ( const auto& i : m_algMap[0] ) { msgStream() << i.first << ": " << i.second << std::endl; }
66 
67  msgStream() << endmsg;
68  }
69 
70  if ( m_algMap[1].size() != 0 ) {
71  info() << "Found " << m_algMap[1].size() << " instances where an Algorithm::execute() produced a FATAL "
72  << "but returned a SUCCESS:" << std::endl;
73 
74  for ( const auto& i : m_algMap[1] ) { msgStream() << i.first << ": " << i.second << std::endl; }
75 
76  msgStream() << endmsg;
77  }
78  return StatusCode::SUCCESS;
79 }
80 
81 void AlgErrorAuditor::incrMap( const std::string& alg, int level ) {
82  auto i = m_algMap[level].find( alg );
83  if ( i != m_algMap[level].end() ) {
84  i->second++;
85  } else {
86  m_algMap[level].emplace( alg, 1 );
87  }
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)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
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:50
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isRecoverable() const
Definition: StatusCode.h:272
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.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
virtual const std::string & name() const =0
Retrieve the name of the instance.