18 #include <boost/regex.hpp> 37 if ( status.
isFailure() ) {
return status ; }
39 string key = m_mode_exc_s.value();
41 auto loc = key.
find(
" ");
46 if (mode ==
"NONE") { m_mode_exc = NONE;
47 }
else if (mode ==
"ALL") { m_mode_exc =
ALL;
49 error() <<
"Unknown mode for Exception handling: \"" << mode
50 <<
"\". Default must be one of \"ALL\" or \"NONE\"" <<
endmsg;
55 if (loc == string::npos) {
63 static const boost::regex
exp{
"[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*([^[:space:]]+)"};
64 static const auto tok_end = boost::sregex_iterator();
65 for (
auto tok_iter = boost::sregex_iterator(
begin(key),
end(key),
exp);
66 tok_iter != tok_end; ++tok_iter)
72 if (VAL ==
"SUCCESS") { m_retCodesExc[TAG] =
SUCCESS;
73 }
else if ( VAL ==
"FAILURE" ) { m_retCodesExc[TAG] =
FAILURE;
74 }
else if ( VAL ==
"REVOVERABLE" ) { m_retCodesExc[TAG] = RECOVERABLE;
75 }
else if ( VAL ==
"RETHROW" ) { m_retCodesExc[TAG] = RETHROW;
76 }
else if ( VAL ==
"DEFAULT" ) { m_retCodesExc[TAG] = DEFAULT;
78 error() <<
"In JobOpts: unknown return code \"" << VAL
79 <<
"\" for Algorithm " << TAG <<
std::endl 80 <<
" Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW" 87 debug() <<
"Will catch exceptions thrown by: " << TAG
88 <<
" -> action: " << VAL <<
endmsg;
93 key = m_mode_err_s.value();
100 if (mode ==
"NONE") { m_mode_err = NONE;
101 }
else if (mode ==
"ALL") { m_mode_err =
ALL;
103 error() <<
"Unknown mode for Error handling: \"" << mode
104 <<
"\". Default must be one of \"ALL\" or \"NONE\"" <<
endmsg;
109 if (loc == string::npos) {
115 for (
auto tok_iter = boost::sregex_iterator(
begin(key),
end(key),
exp);
116 tok_iter != tok_end; ++tok_iter)
118 TAG = (*tok_iter)[1];
119 VAL = (*tok_iter)[2];
122 if (VAL ==
"SUCCESS") { m_retCodesErr[TAG] =
SUCCESS;
123 }
else if ( VAL ==
"FAILURE" ) { m_retCodesErr[TAG] =
FAILURE;
124 }
else if ( VAL ==
"RECOVERABLE" ) { m_retCodesErr[TAG] = RECOVERABLE;
126 error() <<
"In JobOpts: unknown return code \"" << VAL
127 <<
"\" for Algorithm " << TAG <<
std::endl 128 <<
" Must be one of: SUCCESS, FAILURE, RECOVERABLE" 135 debug() <<
"Will process Errors returned by: " << TAG
136 <<
" -> action: " << VAL <<
endmsg;
148 debug() <<
"Handling Error from " << alg.
name() <<
endmsg;
151 auto i = m_retCodesErr.find(alg.
name());
152 if ( i != m_retCodesErr.end()) {
153 switch ( i->second ) {
165 assert (m_mode_err == NONE );
178 auto i = m_retCodesExc.find(alg.
name());
179 if ( i != m_retCodesExc.end()) {
181 switch ( i->second ) {
190 if (m_mode_exc ==
ALL) {
throw; }
191 assert (m_mode_exc == NONE);
200 debug() <<
"Handling unknown exception for " << alg.
name() <<
endmsg;
210 debug() <<
"Handling std:except: \"" << exc.
what() <<
"\" for " 212 return process(alg) ;
221 debug() <<
"Handling GaudiException: \"" << exc <<
"\" for " StatusCode initialize() override
int ALL
message levels --------------------------------------------------------—
Define general base for Gaudi exception.
bool isFailure() const
Test for a status code of FAILURE.
#define DECLARE_COMPONENT(type)
This class is used for returning status codes from appropriate routines.
Simple implementation of IExceptionSvc abstract interface.
StatusCode initialize() override
initialize the service
StatusCode handle(const INamedInterface &o, const GaudiException &e) const override
Handle caught GaudiExceptions.
IInterface compliant class extending IInterface with the name() method.
StatusCode handleErr(const INamedInterface &o, const StatusCode &s) const override
Handle errors.
virtual StatusCode process(const INamedInterface &o) const
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual const std::string & name() const =0
Retrieve the name of the instance.