18 #include <boost/regex.hpp> 37 string key = m_mode_exc_s.value();
39 auto loc = key.
find(
" " );
44 if ( mode ==
"NONE" ) {
46 }
else if ( mode ==
"ALL" ) {
49 error() <<
"Unknown mode for Exception handling: \"" << mode <<
"\". Default must be one of \"ALL\" or \"NONE\"" 55 if ( loc == string::npos ) {
58 key = key.
substr( loc + 1 );
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 ); tok_iter != tok_end; ++tok_iter ) {
66 TAG = ( *tok_iter )[1];
67 VAL = ( *tok_iter )[2];
70 if ( VAL ==
"SUCCESS" ) {
72 }
else if ( VAL ==
"FAILURE" ) {
74 }
else if ( VAL ==
"REVOVERABLE" ) {
75 m_retCodesExc[TAG] = RECOVERABLE;
76 }
else if ( VAL ==
"RETHROW" ) {
77 m_retCodesExc[TAG] = RETHROW;
78 }
else if ( VAL ==
"DEFAULT" ) {
79 m_retCodesExc[TAG] = DEFAULT;
81 error() <<
"In JobOpts: unknown return code \"" << VAL <<
"\" for Algorithm " << TAG <<
std::endl 82 <<
" Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW" <<
endmsg;
88 debug() <<
"Will catch exceptions thrown by: " << TAG <<
" -> action: " << VAL <<
endmsg;
92 key = m_mode_err_s.value();
94 loc = key.
find(
" " );
95 mode = key.
substr( 0, loc );
99 if ( mode ==
"NONE" ) {
101 }
else if ( mode ==
"ALL" ) {
104 error() <<
"Unknown mode for Error handling: \"" << mode <<
"\". Default must be one of \"ALL\" or \"NONE\"" 110 if ( loc == string::npos ) {
113 key = key.
substr( loc + 1 );
116 for (
auto tok_iter = boost::sregex_iterator(
begin( key ),
end( key ),
exp ); tok_iter != tok_end; ++tok_iter ) {
117 TAG = ( *tok_iter )[1];
118 VAL = ( *tok_iter )[2];
121 if ( VAL ==
"SUCCESS" ) {
123 }
else if ( VAL ==
"FAILURE" ) {
125 }
else if ( VAL ==
"RECOVERABLE" ) {
126 m_retCodesErr[TAG] = RECOVERABLE;
128 error() <<
"In JobOpts: unknown return code \"" << VAL <<
"\" for Algorithm " << TAG <<
std::endl 129 <<
" Must be one of: SUCCESS, FAILURE, RECOVERABLE" <<
endmsg;
135 debug() <<
"Will process Errors returned by: " << TAG <<
" -> action: " << VAL <<
endmsg;
147 auto i = m_retCodesErr.find( alg.
name() );
148 if ( i != m_retCodesErr.end() ) {
149 switch ( i->second ) {
166 assert( m_mode_err == NONE );
178 auto i = m_retCodesExc.find( alg.
name() );
179 if ( i != m_retCodesExc.end() ) {
181 switch ( i->second ) {
195 if ( m_mode_exc ==
ALL ) {
198 assert( m_mode_exc == NONE );
205 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Handling unknown exception for " << alg.
name() <<
endmsg;
206 return process( alg );
212 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Handling std:except: \"" << exc.
what() <<
"\" for " << alg.
name() <<
endmsg;
213 return process( alg );
219 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Handling GaudiException: \"" << exc <<
"\" for " << alg.
name() <<
endmsg;
220 return process( alg );
StatusCode initialize() override
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.