18 #include <boost/regex.hpp> 32 if ( status.
isFailure() ) {
return status; }
34 string key = m_mode_exc_s.value();
36 auto loc = key.
find(
" " );
41 if ( mode ==
"NONE" ) {
43 }
else if ( mode ==
"ALL" ) {
46 error() <<
"Unknown mode for Exception handling: \"" << mode <<
"\". Default must be one of \"ALL\" or \"NONE\"" 52 if ( loc == string::npos ) {
55 key = key.
substr( loc + 1 );
60 static const boost::regex
exp{
"[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*([^[:space:]]+)"};
61 static const auto tok_end = boost::sregex_iterator();
62 for (
auto tok_iter = boost::sregex_iterator(
begin( key ),
end( key ),
exp ); tok_iter != tok_end; ++tok_iter ) {
63 TAG = ( *tok_iter )[1];
64 VAL = ( *tok_iter )[2];
67 if ( VAL ==
"SUCCESS" ) {
69 }
else if ( VAL ==
"FAILURE" ) {
71 }
else if ( VAL ==
"REVOVERABLE" ) {
72 m_retCodesExc[TAG] = RECOVERABLE;
73 }
else if ( VAL ==
"RETHROW" ) {
74 m_retCodesExc[TAG] = RETHROW;
75 }
else if ( VAL ==
"DEFAULT" ) {
76 m_retCodesExc[TAG] = DEFAULT;
78 error() <<
"In JobOpts: unknown return code \"" << VAL <<
"\" for Algorithm " << TAG <<
std::endl 79 <<
" Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW" <<
endmsg;
85 debug() <<
"Will catch exceptions thrown by: " << TAG <<
" -> action: " << VAL <<
endmsg;
89 key = m_mode_err_s.value();
91 loc = key.
find(
" " );
92 mode = key.
substr( 0, loc );
96 if ( mode ==
"NONE" ) {
98 }
else if ( mode ==
"ALL" ) {
101 error() <<
"Unknown mode for Error handling: \"" << mode <<
"\". Default must be one of \"ALL\" or \"NONE\"" 107 if ( loc == string::npos ) {
110 key = key.
substr( loc + 1 );
113 for (
auto tok_iter = boost::sregex_iterator(
begin( key ),
end( key ),
exp ); tok_iter != tok_end; ++tok_iter ) {
114 TAG = ( *tok_iter )[1];
115 VAL = ( *tok_iter )[2];
118 if ( VAL ==
"SUCCESS" ) {
120 }
else if ( VAL ==
"FAILURE" ) {
122 }
else if ( VAL ==
"RECOVERABLE" ) {
123 m_retCodesErr[TAG] = RECOVERABLE;
125 error() <<
"In JobOpts: unknown return code \"" << VAL <<
"\" for Algorithm " << TAG <<
std::endl 126 <<
" Must be one of: SUCCESS, FAILURE, RECOVERABLE" <<
endmsg;
132 debug() <<
"Will process Errors returned by: " << TAG <<
" -> action: " << VAL <<
endmsg;
143 auto i = m_retCodesErr.find( alg.
name() );
144 if ( i != m_retCodesErr.end() ) {
145 switch ( i->second ) {
162 assert( m_mode_err == NONE );
173 auto i = m_retCodesExc.find( alg.
name() );
174 if ( i != m_retCodesExc.end() ) {
176 switch ( i->second ) {
190 if ( m_mode_exc ==
ALL ) {
throw; }
191 assert( m_mode_exc == NONE );
197 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Handling unknown exception for " << alg.
name() <<
endmsg;
198 return process( alg );
203 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Handling std:except: \"" << exc.
what() <<
"\" for " << alg.
name() <<
endmsg;
204 return process( alg );
209 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Handling GaudiException: \"" << exc <<
"\" for " << alg.
name() <<
endmsg;
210 return process( alg );
StatusCode initialize() override
Define general base for Gaudi exception.
constexpr static const auto RECOVERABLE
constexpr static const auto SUCCESS
#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.
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.
virtual const std::string & name() const =0
Retrieve the name of the instance.