11 #include "GaudiKernel/ISvcLocator.h"
18 #include <boost/regex.hpp>
28 std::transform(s.begin(), s.end(), s.begin(),
38 , m_mode_exc (
ALL ), m_mode_err( NONE )
39 , m_log(msgSvc(), name )
62 if ( status.
isFailure() ) {
return status ; }
66 string::size_type loc = key.find(
" ");
68 if (loc == std::string::npos) {
71 mode = key.substr(0,loc);
78 }
else if (mode ==
"ALL") {
81 m_log <<
MSG::ERROR <<
"Unknown mode for Exception handling: \"" << mode
82 <<
"\". Default must be one of \"ALL\" or \"NONE\"" <<
endmsg;
87 if (loc == string::npos) {
90 key = key.substr(loc+1);
95 static const boost::regex exp{
"[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*([^[:space:]]+)"};
96 static const auto tok_end = boost::sregex_iterator();
97 for (
auto tok_iter = boost::sregex_iterator(begin(key),
end(key), exp);
98 tok_iter != tok_end; ++tok_iter)
100 TAG = (*tok_iter)[1];
102 VAL = (*tok_iter)[2];
105 if (VAL ==
"SUCCESS") {
107 }
else if ( VAL ==
"FAILURE" ) {
109 }
else if ( VAL ==
"REVOVERABLE" ) {
111 }
else if ( VAL ==
"RETHROW" ) {
113 }
else if ( VAL ==
"DEFAULT" ) {
117 <<
"\" for Algorithm " << TAG << std::endl
118 <<
" Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW"
125 <<
" -> action: " << VAL <<
endmsg;
134 if (loc == std::string::npos) {
137 mode = key.substr(0,loc);
142 if (mode ==
"NONE") {
144 }
else if (mode ==
"ALL") {
148 <<
"\". Default must be one of \"ALL\" or \"NONE\"" <<
endmsg;
153 if (loc == string::npos) {
156 key = key.substr(loc+1);
159 for (
auto tok_iter = boost::sregex_iterator(begin(key),
end(key), exp);
160 tok_iter != tok_end; ++tok_iter)
162 TAG = (*tok_iter)[1];
164 VAL = (*tok_iter)[2];
167 if (VAL ==
"SUCCESS") {
169 }
else if ( VAL ==
"FAILURE" ) {
171 }
else if ( VAL ==
"RECOVERABLE" ) {
175 <<
"\" for Algorithm " << TAG << std::endl
176 <<
" Must be one of: SUCCESS, FAILURE, RECOVERABLE"
183 <<
" -> action: " << VAL <<
endmsg;
208 if (m_retCodesErr.find(alg.
name()) != m_retCodesErr.end()) {
228 if (m_mode_err ==
ALL) {
233 assert (m_mode_err == NONE );
248 if (m_retCodesExc.find(alg.
name()) != m_retCodesExc.end()) {
267 if (m_mode_exc ==
ALL) {
270 assert (m_mode_exc == NONE);
282 m_log <<
MSG::DEBUG <<
"Handling unknown exception for " << alg.
name()
291 const std::exception & exc )
const
293 m_log <<
MSG::DEBUG <<
"Handling std:except: \"" << exc.what() <<
"\" for "
296 return process(alg) ;
305 m_log <<
MSG::DEBUG <<
"Handling GaudiException: \"" << exc <<
"\" for "
IntegerProperty m_outputLevel
Service output level.
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Gaudi::StateMachine::State m_state
Service state.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode initialize()
initialize the service
std::map< std::string, ReturnState > m_retCodesErr
virtual StatusCode handleErr(const INamedInterface &o, const StatusCode &s) const
Handle errors.
virtual StatusCode handle(const INamedInterface &o, const GaudiException &e) const
Handle caught GaudiExceptions.
bool isFailure() const
Test for a status code of FAILURE.
virtual const std::string & name() const =0
Retrieve the name of the instance.
StringProperty m_mode_err_s
ExceptionSvc()
no default constructor
int ALL
message levels --------------------------------------------------------—
#define DECLARE_COMPONENT(type)
This class is used for returning status codes from appropriate routines.
Simple implementation of IExceptionSvc abstract interface.
StringProperty m_mode_exc_s
const TYPE & value() const
explicit conversion
std::map< std::string, ReturnState > m_retCodesExc
IInterface compliant class extending IInterface with the name() method.
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
virtual StatusCode finalize()
finalize the service
void setLevel(int level)
Update outputlevel.
Templated class to add the standard messaging functionalities.
virtual ~ExceptionSvc()
Destructor.
virtual StatusCode process(const INamedInterface &o) const
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
void toupper(std::string &s)
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).