28 #include <boost/regex.hpp>
42 if ( status.
isFailure() ) {
return status; }
44 string key = m_mode_exc_s.value();
46 auto loc =
key.find(
" " );
51 if ( mode ==
"NONE" ) {
53 }
else if ( mode ==
"ALL" ) {
56 error() <<
"Unknown mode for Exception handling: \"" << mode <<
"\". Default must be one of \"ALL\" or \"NONE\""
62 if ( loc == string::npos ) {
65 key =
key.substr( loc + 1 );
70 static const boost::regex
exp{
"[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*([^[:space:]]+)" };
71 static const auto tok_end = boost::sregex_iterator();
72 for (
auto tok_iter = boost::sregex_iterator(
begin(
key ),
end(
key ),
exp ); tok_iter != tok_end; ++tok_iter ) {
73 TAG = ( *tok_iter )[1];
74 VAL = ( *tok_iter )[2];
77 if ( VAL ==
"SUCCESS" ) {
79 }
else if ( VAL ==
"FAILURE" ) {
81 }
else if ( VAL ==
"REVOVERABLE" ) {
82 m_retCodesExc[TAG] = RECOVERABLE;
83 }
else if ( VAL ==
"RETHROW" ) {
84 m_retCodesExc[TAG] = RETHROW;
85 }
else if ( VAL ==
"DEFAULT" ) {
86 m_retCodesExc[TAG] = DEFAULT;
88 error() <<
"In JobOpts: unknown return code \"" << VAL <<
"\" for Algorithm " << TAG <<
std::endl
89 <<
" Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW" <<
endmsg;
95 debug() <<
"Will catch exceptions thrown by: " << TAG <<
" -> action: " << VAL <<
endmsg;
99 key = m_mode_err_s.value();
101 loc =
key.find(
" " );
102 mode =
key.substr( 0, loc );
106 if ( mode ==
"NONE" ) {
108 }
else if ( mode ==
"ALL" ) {
111 error() <<
"Unknown mode for Error handling: \"" << mode <<
"\". Default must be one of \"ALL\" or \"NONE\""
117 if ( loc == string::npos ) {
120 key =
key.substr( loc + 1 );
123 for (
auto tok_iter = boost::sregex_iterator(
begin(
key ),
end(
key ),
exp ); tok_iter != tok_end; ++tok_iter ) {
124 TAG = ( *tok_iter )[1];
125 VAL = ( *tok_iter )[2];
128 if ( VAL ==
"SUCCESS" ) {
130 }
else if ( VAL ==
"FAILURE" ) {
132 }
else if ( VAL ==
"RECOVERABLE" ) {
133 m_retCodesErr[TAG] = RECOVERABLE;
135 error() <<
"In JobOpts: unknown return code \"" << VAL <<
"\" for Algorithm " << TAG <<
std::endl
136 <<
" Must be one of: SUCCESS, FAILURE, RECOVERABLE" <<
endmsg;
142 debug() <<
"Will process Errors returned by: " << TAG <<
" -> action: " << VAL <<
endmsg;
153 auto i = m_retCodesErr.find(
alg.name() );
154 if ( i != m_retCodesErr.end() ) {
155 switch ( i->second ) {
172 assert( m_mode_err == NONE );
183 auto i = m_retCodesExc.find(
alg.name() );
184 if ( i != m_retCodesExc.end() ) {
186 switch ( i->second ) {
200 if ( m_mode_exc ==
ALL ) {
throw; }
201 assert( m_mode_exc == NONE );
207 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Handling unknown exception for " <<
alg.name() <<
endmsg;
213 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Handling std:except: \"" << exc.
what() <<
"\" for " <<
alg.name() <<
endmsg;
219 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Handling GaudiException: \"" << exc <<
"\" for " <<
alg.name() <<
endmsg;