|
Gaudi Framework, version v21r9 |
| Home | Generated: 3 May 2010 |
#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 | |
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 > |
Definition at line 24 of file ExceptionSvc.h.
enum ExceptionSvc::Policy [private] |
enum ExceptionSvc::ReturnState [private] |
Definition at line 67 of file ExceptionSvc.h.
00067 { 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 39 of file ExceptionSvc.cpp.
00040 : base_class( name, svc ) 00041 , m_mode_exc ( ALL ), m_mode_err( NONE ) 00042 , m_log(msgSvc(), name ) 00043 { 00044 // for exceptions 00045 declareProperty( "Catch" , m_mode_exc_s="ALL" ) ; 00046 00047 // for return codes 00048 declareProperty( "Errors" , m_mode_err_s="NONE" ) ; 00049 }
| ExceptionSvc::~ExceptionSvc | ( | ) | [virtual] |
| ExceptionSvc::ExceptionSvc | ( | ) | [private] |
no default constructor
| ExceptionSvc::ExceptionSvc | ( | const ExceptionSvc & | ) | [private] |
no copy constructor
| StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o, | |
| const GaudiException & | e | |||
| ) | const [virtual] |
Handle caught GaudiExceptions.
Handle caught exceptions
Implements IExceptionSvc.
Definition at line 333 of file ExceptionSvc.cpp.
00335 { 00336 00337 m_log << MSG::DEBUG << "Handling GaudiExcept for " << alg.name() << endmsg; 00338 00339 // is this Alg special? 00340 if (m_retCodesExc.find(alg.name()) != m_retCodesExc.end()) { 00341 ReturnState iret = m_retCodesExc.find(alg.name())->second; 00342 00343 switch ( iret ) { 00344 case DEFAULT: 00345 return exc.code(); 00346 case SUCCESS: 00347 return StatusCode::SUCCESS; 00348 case FAILURE: 00349 return StatusCode::FAILURE; 00350 case RECOVERABLE: 00351 return StatusCode::RECOVERABLE; 00352 case RETHROW: 00353 throw ( exc ); 00354 } 00355 00356 } else { 00357 00358 if (m_mode_exc == ALL) { 00359 throw (exc); 00360 } else { 00361 assert (m_mode_exc == NONE); 00362 return StatusCode::FAILURE; 00363 } 00364 } 00365 00366 00367 return StatusCode::FAILURE; 00368 00369 }
| StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o, | |
| const std::exception & | e | |||
| ) | const [virtual] |
Handle caught std::exceptions.
Handle caught exceptions
Implements IExceptionSvc.
Definition at line 294 of file ExceptionSvc.cpp.
00296 { 00297 m_log << MSG::DEBUG << "Handling std:except for " << alg.name() << endmsg; 00298 00299 // is this Alg special? 00300 if (m_retCodesExc.find(alg.name()) != m_retCodesExc.end()) { 00301 ReturnState iret = m_retCodesExc.find(alg.name())->second; 00302 00303 switch ( iret ) { 00304 case DEFAULT: 00305 // there is no default 00306 return StatusCode::FAILURE; 00307 case SUCCESS: 00308 return StatusCode::SUCCESS; 00309 case FAILURE: 00310 return StatusCode::FAILURE; 00311 case RECOVERABLE: 00312 return StatusCode::RECOVERABLE; 00313 case RETHROW: 00314 throw ( exc ); 00315 } 00316 00317 } else { 00318 00319 if (m_mode_exc == ALL) { 00320 throw (exc); 00321 } else { 00322 assert (m_mode_exc == NONE); 00323 return StatusCode::FAILURE; 00324 } 00325 } 00326 00327 return StatusCode::FAILURE; 00328 00329 }
| StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o | ) | const [virtual] |
Handle caught (unknown)exceptions.
Handle caught exceptions
Implements IExceptionSvc.
Definition at line 256 of file ExceptionSvc.cpp.
00257 { 00258 m_log << MSG::DEBUG << "Handling unknown exception for " << alg.name() << endmsg; 00259 00260 // is this Alg special? 00261 if (m_retCodesExc.find(alg.name()) != m_retCodesExc.end()) { 00262 ReturnState iret = m_retCodesExc.find(alg.name())->second; 00263 00264 switch ( iret ) { 00265 case DEFAULT: 00266 // there is no default 00267 return StatusCode::FAILURE; 00268 case SUCCESS: 00269 return StatusCode::SUCCESS; 00270 case FAILURE: 00271 return StatusCode::FAILURE; 00272 case RECOVERABLE: 00273 return StatusCode::RECOVERABLE; 00274 case RETHROW: 00275 throw; 00276 } 00277 00278 } else { 00279 00280 if (m_mode_exc == ALL) { 00281 throw; 00282 } else { 00283 assert (m_mode_exc == NONE); 00284 return StatusCode::FAILURE; 00285 } 00286 } 00287 00288 return StatusCode::FAILURE; 00289 00290 }
| StatusCode ExceptionSvc::handleErr | ( | const INamedInterface & | o, | |
| const StatusCode & | s | |||
| ) | const [virtual] |
Handle errors.
Handle errors
Implements IExceptionSvc.
Definition at line 213 of file ExceptionSvc.cpp.
00215 { 00216 m_log << MSG::DEBUG << "Handling Error from " << alg.name() << endmsg; 00217 00218 // is this Alg special? 00219 if (m_retCodesErr.find(alg.name()) != m_retCodesErr.end()) { 00220 ReturnState iret = m_retCodesErr.find(alg.name())->second; 00221 00222 switch ( iret ) { 00223 case SUCCESS: 00224 return StatusCode::SUCCESS; 00225 case FAILURE: 00226 return StatusCode::FAILURE; 00227 case RECOVERABLE: 00228 return StatusCode::RECOVERABLE; 00229 case RETHROW: 00230 // should never get here 00231 break; 00232 case DEFAULT: 00233 // should never get here 00234 break; 00235 } 00236 00237 } else { 00238 00239 if (m_mode_err == ALL) { 00240 // turn it into a FAILURE 00241 return StatusCode::FAILURE; 00242 00243 } else { 00244 assert (m_mode_err == NONE ); 00245 // don't touch the return code 00246 return st; 00247 } 00248 } 00249 00250 return StatusCode::FAILURE; 00251 00252 }
| StatusCode ExceptionSvc::initialize | ( | ) | [virtual] |
initialize the service
Reimplemented from Service.
Definition at line 61 of file ExceptionSvc.cpp.
00061 { 00062 StatusCode status = Service::initialize(); 00063 m_log.setLevel( m_outputLevel.value() ); 00064 00065 if ( status.isFailure() ) { return status ; } // RETURN 00066 00067 string key = m_mode_exc_s.value(); 00068 00069 string::size_type loc = key.find(" "); 00070 std::string mode; 00071 if (loc == std::string::npos) { 00072 mode = key; 00073 } else { 00074 mode = key.substr(0,loc); 00075 } 00076 00077 toupper(mode); 00078 00079 if (mode == "NONE") { 00080 m_mode_exc = NONE; 00081 } else if (mode == "ALL") { 00082 m_mode_exc = ALL; 00083 } else { 00084 m_log << MSG::ERROR << "Unknown mode for Exception handling: \"" << mode 00085 << "\". Default must be one of \"ALL\" or \"NONE\"" << endmsg; 00086 m_state = Gaudi::StateMachine::OFFLINE; 00087 return StatusCode::FAILURE; 00088 } 00089 00090 if (loc == string::npos) { 00091 key = ""; 00092 } else { 00093 key = key.substr(loc+1,key.length()); 00094 } 00095 00096 Tokenizer tok(true); 00097 std::string val,VAL,TAG; 00098 00099 tok.analyse( key, " ", "", "", "=", "", ""); 00100 00101 for ( Tokenizer::Items::iterator i = tok.items().begin(); 00102 i != tok.items().end(); i++) { 00103 const std::string& tag = (*i).tag(); 00104 TAG = tag; 00105 00106 val = (*i).value(); 00107 VAL = val; 00108 toupper(VAL); 00109 00110 if (VAL == "SUCCESS") { 00111 m_retCodesExc[TAG] = SUCCESS; 00112 } else if ( VAL == "FAILURE" ) { 00113 m_retCodesExc[TAG] = FAILURE; 00114 } else if ( VAL == "REVOVERABLE" ) { 00115 m_retCodesExc[TAG] = RECOVERABLE; 00116 } else if ( VAL == "RETHROW" ) { 00117 m_retCodesExc[TAG] = RETHROW; 00118 } else if ( VAL == "DEFAULT" ) { 00119 m_retCodesExc[TAG] = DEFAULT; 00120 } else { 00121 m_log << MSG::ERROR << "In JobOpts: unknown return code \"" << VAL 00122 << "\" for Algorithm " << TAG << std::endl 00123 << " Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW" 00124 << endmsg; 00125 m_state = Gaudi::StateMachine::OFFLINE; 00126 return StatusCode::FAILURE; 00127 } 00128 00129 m_log << MSG::DEBUG << "Will catch exceptions thrown by: " << TAG 00130 << " -> action: " << VAL << endmsg; 00131 00132 } 00133 00134 // now process errors 00135 00136 key = m_mode_err_s.value(); 00137 00138 loc = key.find(" "); 00139 if (loc == std::string::npos) { 00140 mode = key; 00141 } else { 00142 mode = key.substr(0,loc); 00143 } 00144 00145 toupper(mode); 00146 00147 if (mode == "NONE") { 00148 m_mode_err = NONE; 00149 } else if (mode == "ALL") { 00150 m_mode_err = ALL; 00151 } else { 00152 m_log << MSG::ERROR << "Unknown mode for Error handling: \"" << mode 00153 << "\". Default must be one of \"ALL\" or \"NONE\"" << endmsg; 00154 m_state = Gaudi::StateMachine::OFFLINE; 00155 return StatusCode::FAILURE; 00156 } 00157 00158 if (loc == string::npos) { 00159 key = ""; 00160 } else { 00161 key = key.substr(loc+1,key.length()); 00162 } 00163 00164 Tokenizer tok2(true); 00165 tok2.analyse( key, " ", "", "", "=", "", ""); 00166 00167 for ( Tokenizer::Items::iterator i = tok2.items().begin(); 00168 i != tok2.items().end(); i++) { 00169 const std::string& tag = (*i).tag(); 00170 TAG = tag; 00171 00172 val = (*i).value(); 00173 VAL = val; 00174 toupper(VAL); 00175 00176 if (VAL == "SUCCESS") { 00177 m_retCodesErr[TAG] = SUCCESS; 00178 } else if ( VAL == "FAILURE" ) { 00179 m_retCodesErr[TAG] = FAILURE; 00180 } else if ( VAL == "RECOVERABLE" ) { 00181 m_retCodesErr[TAG] = RECOVERABLE; 00182 } else { 00183 m_log << MSG::ERROR << "In JobOpts: unknown return code \"" << VAL 00184 << "\" for Algorithm " << TAG << std::endl 00185 << " Must be one of: SUCCESS, FAILURE, RECOVERABLE" 00186 << endmsg; 00187 m_state = Gaudi::StateMachine::OFFLINE; 00188 return StatusCode::FAILURE; 00189 } 00190 00191 m_log << MSG::DEBUG << "Will process Errors returned by: " << TAG 00192 << " -> action: " << VAL << endmsg; 00193 00194 } 00195 00196 00197 00198 return status; 00199 }
| StatusCode ExceptionSvc::finalize | ( | void | ) | [virtual] |
finalize the service
Reimplemented from Service.
Definition at line 204 of file ExceptionSvc.cpp.
00204 { 00205 StatusCode status = Service::finalize(); 00206 00207 return status; 00208 }
| ExceptionSvc& ExceptionSvc::operator= | ( | const ExceptionSvc & | ) | [private] |
no assignement
friend class SvcFactory< ExceptionSvc > [friend] |
Definition at line 25 of file ExceptionSvc.h.
Policy ExceptionSvc::m_mode_exc [private] |
Definition at line 69 of file ExceptionSvc.h.
Policy ExceptionSvc::m_mode_err [private] |
Definition at line 69 of file ExceptionSvc.h.
StringProperty ExceptionSvc::m_mode_exc_s [private] |
Definition at line 70 of file ExceptionSvc.h.
StringProperty ExceptionSvc::m_mode_err_s [private] |
Definition at line 70 of file ExceptionSvc.h.
Definition at line 71 of file ExceptionSvc.h.
Definition at line 71 of file ExceptionSvc.h.
MsgStream ExceptionSvc::m_log [mutable, private] |
Definition at line 73 of file ExceptionSvc.h.