Gaudi Framework, version v25r0
Home
Generated: Mon Feb 17 2014
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
GaudiAud
src
AlgErrorAuditor.cpp
Go to the documentation of this file.
1
#include "
AlgErrorAuditor.h
"
2
#include "
GaudiKernel/MsgStream.h
"
3
#include "
GaudiKernel/IMessageSvc.h
"
4
#include "
GaudiKernel/GaudiException.h
"
5
6
DECLARE_COMPONENT
(
AlgErrorAuditor
)
7
8
AlgErrorAuditor
::
AlgErrorAuditor
(const
std
::
string
& name,
ISvcLocator
* pSvcLocator)
9
:
Auditor
(name, pSvcLocator), m_error(0), m_fatal(0) {
10
11
declareProperty(
"Abort"
, m_abort =
false
,
12
"Abort job upon illegal Algorithm return code"
);
13
declareProperty(
"Throw"
, m_throw =
false
,
14
"Throw GaudiException upon illegal Algorithm return code"
);
15
}
16
17
AlgErrorAuditor::~AlgErrorAuditor
(){
18
}
19
20
21
void
22
AlgErrorAuditor:: beforeExecute
(
INamedInterface
* ){
23
m_error
=
msgSvc
()->messageCount(
MSG::ERROR
);
24
m_fatal
=
msgSvc
()->messageCount(
MSG::FATAL
);
25
}
26
27
StatusCode
28
AlgErrorAuditor:: initialize
() {
29
30
if
(
m_abort
&&
m_throw
) {
31
MsgStream
log
(
msgSvc
(),
name
());
32
log <<
MSG::INFO
<<
"Both \"Throw\" and \"Abort\" options have been set."
33
<<
" Abort takes precedence."
<<
endmsg
;
34
}
35
36
return
StatusCode::SUCCESS
;
37
}
38
39
40
void
41
AlgErrorAuditor:: afterExecute
(
INamedInterface
* alg,
const
StatusCode
&
sc
) {
42
43
bool
fail(
false
);
44
if
(
msgSvc
()->messageCount(
MSG::ERROR
) !=
m_error
&& ! sc.
isRecoverable
() ) {
45
std::ostringstream
os;
46
os <<
"Illegal Return Code: Algorithm "
<< alg->
name
()
47
<<
" reported an ERROR, but returned a StatusCode \""
<< sc <<
"\""
;
48
os <<
std::endl
<<
"Error policy described in "
49
<<
"https://twiki.cern.ch/twiki/bin/view/Atlas/ReportingErrors"
;
50
51
MsgStream
log
(
msgSvc
(),
name
());
52
log <<
MSG::ERROR
<< os.str() <<
endmsg
;
53
incrMap
(alg->
name
(), 0);
54
fail =
true
;
55
56
if
(
m_throw
&& !
m_abort
) {
57
throw
GaudiException
(os.str(),
"AlgErrorAuditor"
,0);
58
}
59
}
60
61
if
(
msgSvc
()->messageCount(
MSG::FATAL
) !=
m_fatal
&&
62
sc !=
StatusCode::FAILURE
) {
63
std::ostringstream
os;
64
os <<
"Illegal Return Code: Algorithm "
<< alg->
name
()
65
<<
" reported a FATAL, but returned a StatusCode \""
<< sc <<
"\""
;
66
os <<
std::endl
<<
"Error policy described in "
67
<<
"https://twiki.cern.ch/twiki/bin/view/Atlas/ReportingErrors"
;
68
69
MsgStream
log
(
msgSvc
(),
name
());
70
log <<
MSG::ERROR
<< os.str() <<
endmsg
;
71
incrMap
(alg->
name
(), 1);
72
fail =
true
;
73
74
if
(
m_throw
&& !
m_abort
) {
75
throw
GaudiException
(os.str(),
"AlgErrorAuditor"
,0);
76
}
77
78
}
79
80
if
(fail &&
m_abort
) {
81
abort
();
82
}
83
84
}
85
86
StatusCode
87
AlgErrorAuditor::finalize
() {
88
89
90
std::map<std::string,int>::const_iterator
itr;
91
if
(
m_algMap
[0].size() != 0) {
92
MsgStream
log
(
msgSvc
(),
name
());
93
log <<
MSG::INFO
<<
"Found "
<<
m_algMap
[0].
size
()
94
<<
" instances where an Algorithm::execute() produced an ERROR "
95
<<
"but returned a SUCCESS:"
<<
std::endl
;
96
97
for
(itr =
m_algMap
[0].begin(); itr !=
m_algMap
[0].
end
(); ++itr) {
98
log << itr->first <<
": "
<< itr->second <<
std::endl
;
99
}
100
101
log <<
endmsg
;
102
}
103
104
if
(
m_algMap
[1].size() != 0) {
105
MsgStream
log
(
msgSvc
(),
name
());
106
log <<
MSG::INFO
<<
"Found "
<<
m_algMap
[1].
size
()
107
<<
" instances where an Algorithm::execute() produced a FATAL "
108
<<
"but returned a SUCCESS:"
<<
std::endl
;
109
110
for
(itr =
m_algMap
[1].begin(); itr !=
m_algMap
[1].
end
(); ++itr) {
111
log << itr->first <<
": "
<< itr->second <<
std::endl
;
112
}
113
114
log <<
endmsg
;
115
}
116
117
118
return
StatusCode::SUCCESS
;
119
120
}
121
122
void
123
AlgErrorAuditor::incrMap
(
const
std::string
& alg,
int
level
) {
124
std::map<std::string, int>::iterator
itr;
125
if
( (itr=
m_algMap
[level].
find
(alg)) !=
m_algMap
[level].
end
()) {
126
itr->second++;
127
}
else
{
128
m_algMap
[
level
].
insert
(
std::pair<std::string,int>
(alg,1) );
129
}
130
}
131
Generated at Mon Feb 17 2014 14:37:39 for Gaudi Framework, version v25r0 by
Doxygen
version 1.8.2 written by
Dimitri van Heesch
, © 1997-2004