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;
208 return process(
alg );
213 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Handling std:except: \"" << exc.
what() <<
"\" for " <<
alg.name() <<
endmsg;
214 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.
constexpr static const auto RECOVERABLE
constexpr static const auto SUCCESS
StatusCode handle(const INamedInterface &o, const GaudiException &e) const override
Handle caught GaudiExceptions.
#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 handleErr(const INamedInterface &o, const StatusCode &s) const override
Handle errors.
IInterface compliant class extending IInterface with the name() method.
constexpr static const auto FAILURE
virtual StatusCode process(const INamedInterface &o) const
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.