Gaudi Framework, version v23r0 |
Home | Generated: Mon Jan 30 2012 |
Simple implementation of IExceptionSvc abstract interface. More...
#include <ExceptionSvc.h>
Public Member Functions | |
virtual StatusCode | handle (const INamedInterface &o, const GaudiException &e) const |
Handle caught GaudiExceptions. | |
virtual StatusCode | handle (const INamedInterface &o, const std::exception &e) const |
Handle caught std::exceptions. | |
virtual StatusCode | handle (const INamedInterface &o) const |
Handle caught (unknown)exceptions. | |
virtual StatusCode | handleErr (const INamedInterface &o, const StatusCode &s) const |
Handle errors. | |
virtual StatusCode | initialize () |
initialize the service | |
virtual StatusCode | finalize () |
finalize the service | |
ExceptionSvc (const std::string &name, ISvcLocator *svc) | |
standard constructor | |
virtual | ~ExceptionSvc () |
Destructor. | |
Private Types | |
enum | Policy { ALL, NONE } |
enum | ReturnState { SUCCESS, FAILURE, RECOVERABLE, RETHROW, DEFAULT } |
Private Member Functions | |
ExceptionSvc () | |
no default constructor | |
ExceptionSvc (const ExceptionSvc &) | |
no copy constructor | |
ExceptionSvc & | operator= (const ExceptionSvc &) |
no assignement | |
virtual StatusCode | process (const INamedInterface &o) const |
Private Attributes | |
Policy | m_mode_exc |
Policy | m_mode_err |
StringProperty | m_mode_exc_s |
StringProperty | m_mode_err_s |
std::map< std::string, ReturnState > | m_retCodesExc |
std::map< std::string, ReturnState > | m_retCodesErr |
MsgStream | m_log |
Friends | |
class | SvcFactory< ExceptionSvc > |
Simple implementation of IExceptionSvc abstract interface.
Definition at line 20 of file ExceptionSvc.h.
enum ExceptionSvc::Policy [private] |
enum ExceptionSvc::ReturnState [private] |
Definition at line 65 of file ExceptionSvc.h.
{ SUCCESS, FAILURE, RECOVERABLE, RETHROW, DEFAULT };
ExceptionSvc::ExceptionSvc | ( | const std::string & | name, |
ISvcLocator * | svc | ||
) |
standard constructor
name | service instance name |
pSvc | pointer to Service Locator |
Definition at line 36 of file ExceptionSvc.cpp.
: base_class( name, svc ) , m_mode_exc ( ALL ), m_mode_err( NONE ) , m_log(msgSvc(), name ) { // for exceptions declareProperty( "Catch" , m_mode_exc_s="ALL" ) ; // for return codes declareProperty( "Errors" , m_mode_err_s="NONE" ) ; }
ExceptionSvc::~ExceptionSvc | ( | ) | [virtual] |
ExceptionSvc::ExceptionSvc | ( | ) | [private] |
no default constructor
ExceptionSvc::ExceptionSvc | ( | const ExceptionSvc & | ) | [private] |
no copy constructor
StatusCode ExceptionSvc::finalize | ( | ) | [virtual] |
finalize the service
Reimplemented from Service.
Definition at line 199 of file ExceptionSvc.cpp.
{ StatusCode status = Service::finalize(); return status; }
StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o, |
const std::exception & | e | ||
) | const [virtual] |
Handle caught std::exceptions.
Handle caught exceptions
Implements IExceptionSvc.
Definition at line 296 of file ExceptionSvc.cpp.
{ m_log << MSG::DEBUG << "Handling std:except: \"" << exc.what() << "\" for " << alg.name() << endmsg; return process(alg) ; }
StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o, |
const GaudiException & | e | ||
) | const [virtual] |
Handle caught GaudiExceptions.
Handle caught exceptions
Implements IExceptionSvc.
Definition at line 308 of file ExceptionSvc.cpp.
{ m_log << MSG::DEBUG << "Handling GaudiException: \"" << exc << "\" for " << alg.name() << endmsg; return process(alg); }
StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o ) | const [virtual] |
Handle caught (unknown)exceptions.
Handle caught exceptions
Implements IExceptionSvc.
Definition at line 286 of file ExceptionSvc.cpp.
{ m_log << MSG::DEBUG << "Handling unknown exception for " << alg.name() << endmsg; return process(alg); }
StatusCode ExceptionSvc::handleErr | ( | const INamedInterface & | o, |
const StatusCode & | s | ||
) | const [virtual] |
Handle errors.
Handle errors
Implements IExceptionSvc.
Definition at line 208 of file ExceptionSvc.cpp.
{ m_log << MSG::DEBUG << "Handling Error from " << alg.name() << endmsg; // is this Alg special? if (m_retCodesErr.find(alg.name()) != m_retCodesErr.end()) { ReturnState iret = m_retCodesErr.find(alg.name())->second; switch ( iret ) { case SUCCESS: return StatusCode::SUCCESS; case FAILURE: return StatusCode::FAILURE; case RECOVERABLE: return StatusCode::RECOVERABLE; case RETHROW: // should never get here break; case DEFAULT: // should never get here break; } } else { if (m_mode_err == ALL) { // turn it into a FAILURE return StatusCode::FAILURE; } else { assert (m_mode_err == NONE ); // don't touch the return code return st; } } return StatusCode::FAILURE; }
StatusCode ExceptionSvc::initialize | ( | ) | [virtual] |
initialize the service
Reimplemented from Service.
Definition at line 58 of file ExceptionSvc.cpp.
{ StatusCode status = Service::initialize(); m_log.setLevel( m_outputLevel.value() ); if ( status.isFailure() ) { return status ; } // RETURN string key = m_mode_exc_s.value(); string::size_type loc = key.find(" "); std::string mode; if (loc == std::string::npos) { mode = key; } else { mode = key.substr(0,loc); } toupper(mode); if (mode == "NONE") { m_mode_exc = NONE; } else if (mode == "ALL") { m_mode_exc = ALL; } else { m_log << MSG::ERROR << "Unknown mode for Exception handling: \"" << mode << "\". Default must be one of \"ALL\" or \"NONE\"" << endmsg; m_state = Gaudi::StateMachine::OFFLINE; return StatusCode::FAILURE; } if (loc == string::npos) { key = ""; } else { key = key.substr(loc+1,key.length()); } Tokenizer tok(true); std::string val,VAL,TAG; tok.analyse( key, " ", "", "", "=", "", ""); for ( Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); i++) { const std::string& tag = (*i).tag(); TAG = tag; val = (*i).value(); VAL = val; toupper(VAL); if (VAL == "SUCCESS") { m_retCodesExc[TAG] = SUCCESS; } else if ( VAL == "FAILURE" ) { m_retCodesExc[TAG] = FAILURE; } else if ( VAL == "REVOVERABLE" ) { m_retCodesExc[TAG] = RECOVERABLE; } else if ( VAL == "RETHROW" ) { m_retCodesExc[TAG] = RETHROW; } else if ( VAL == "DEFAULT" ) { m_retCodesExc[TAG] = DEFAULT; } else { m_log << MSG::ERROR << "In JobOpts: unknown return code \"" << VAL << "\" for Algorithm " << TAG << std::endl << " Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW" << endmsg; m_state = Gaudi::StateMachine::OFFLINE; return StatusCode::FAILURE; } m_log << MSG::DEBUG << "Will catch exceptions thrown by: " << TAG << " -> action: " << VAL << endmsg; } // now process errors key = m_mode_err_s.value(); loc = key.find(" "); if (loc == std::string::npos) { mode = key; } else { mode = key.substr(0,loc); } toupper(mode); if (mode == "NONE") { m_mode_err = NONE; } else if (mode == "ALL") { m_mode_err = ALL; } else { m_log << MSG::ERROR << "Unknown mode for Error handling: \"" << mode << "\". Default must be one of \"ALL\" or \"NONE\"" << endmsg; m_state = Gaudi::StateMachine::OFFLINE; return StatusCode::FAILURE; } if (loc == string::npos) { key = ""; } else { key = key.substr(loc+1,key.length()); } Tokenizer tok2(true); tok2.analyse( key, " ", "", "", "=", "", ""); for ( Tokenizer::Items::iterator i = tok2.items().begin(); i != tok2.items().end(); i++) { const std::string& tag = (*i).tag(); TAG = tag; val = (*i).value(); VAL = val; toupper(VAL); if (VAL == "SUCCESS") { m_retCodesErr[TAG] = SUCCESS; } else if ( VAL == "FAILURE" ) { m_retCodesErr[TAG] = FAILURE; } else if ( VAL == "RECOVERABLE" ) { m_retCodesErr[TAG] = RECOVERABLE; } else { m_log << MSG::ERROR << "In JobOpts: unknown return code \"" << VAL << "\" for Algorithm " << TAG << std::endl << " Must be one of: SUCCESS, FAILURE, RECOVERABLE" << endmsg; m_state = Gaudi::StateMachine::OFFLINE; return StatusCode::FAILURE; } m_log << MSG::DEBUG << "Will process Errors returned by: " << TAG << " -> action: " << VAL << endmsg; } return status; }
ExceptionSvc& ExceptionSvc::operator= | ( | const ExceptionSvc & | ) | [private] |
no assignement
StatusCode ExceptionSvc::process | ( | const INamedInterface & | o ) | const [private, virtual] |
Definition at line 250 of file ExceptionSvc.cpp.
{ // is this Alg special? if (m_retCodesExc.find(alg.name()) != m_retCodesExc.end()) { ReturnState iret = m_retCodesExc.find(alg.name())->second; switch ( iret ) { case DEFAULT: // there is no default return StatusCode::FAILURE; case SUCCESS: return StatusCode::SUCCESS; case FAILURE: return StatusCode::FAILURE; case RECOVERABLE: return StatusCode::RECOVERABLE; case RETHROW: throw; } } else { if (m_mode_exc == ALL) { throw; } else { assert (m_mode_exc == NONE); return StatusCode::FAILURE; } } return StatusCode::FAILURE; }
friend class SvcFactory< ExceptionSvc > [friend] |
Definition at line 21 of file ExceptionSvc.h.
MsgStream ExceptionSvc::m_log [mutable, private] |
Definition at line 71 of file ExceptionSvc.h.
Policy ExceptionSvc::m_mode_err [private] |
Definition at line 67 of file ExceptionSvc.h.
StringProperty ExceptionSvc::m_mode_err_s [private] |
Definition at line 68 of file ExceptionSvc.h.
Policy ExceptionSvc::m_mode_exc [private] |
Definition at line 67 of file ExceptionSvc.h.
StringProperty ExceptionSvc::m_mode_exc_s [private] |
Definition at line 68 of file ExceptionSvc.h.
Definition at line 69 of file ExceptionSvc.h.
Definition at line 69 of file ExceptionSvc.h.