| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# ExceptionSvc Class Reference

`#include <ExceptionSvc.h>`

Inheritance diagram for ExceptionSvc:

[legend]
Collaboration diagram for ExceptionSvc:

[legend]
List of all members.

## Detailed Description

Simple implementationof IExceptionSvc abstract interface.

Author:
  (1) ATLAS collaboration

  (2) modified by Vanya BELYAEV ibelyaev@physics.syr.edu 2007-03-08

Definition at line 23 of file ExceptionSvc.h.

## Public Member Functions
virtual StatusCode | handle (const INamedInterface &o, const GaudiException &e) const
| Handle caught GaudiExceptions Handle caught exceptions.
virtual StatusCode | handle (const INamedInterface &o, const std::exception &e) const
| Handle caught std::exceptions Handle caught exceptions.
virtual StatusCode | handle (const INamedInterface &o) const
| Handle caught (unknown)exceptions Handle caught exceptions.
virtual StatusCode | handleErr (const INamedInterface &o, const StatusCode &s) const
| Handle errors Handle errors.
virtual StatusCode | initialize ()
| initialize the service
virtual StatusCode | finalize ()
| finalize the service
virtual StatusCode | queryInterface (const InterfaceID &iid, void **ppvi)
| query the interface
| ExceptionSvc (const std::string &name, ISvcLocator *svc)
| standard constructor
virtual | ~ExceptionSvc ()
| Destructor.
## Private Types
enum | ExceptState { ALL, NONE, LIST }
enum | ReturnState { DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW }
## Private Member Functions
| ExceptionSvc ()
| no default constructor
| ExceptionSvc (const ExceptionSvc &)
| no copy constructor
ExceptionSvc & | operator= (const ExceptionSvc &)
| no assignement
## Private Attributes
std::string | m_mode_s
ExceptState | m_mode
StringArrayProperty | m_algs_v
std::set< std::string > | m_algs
std::map< std::string, ReturnState > | m_retCodes
## Friends
class | SvcFactory< ExceptionSvc >

## Member Enumeration Documentation

enum ExceptionSvc::ExceptState`[private]`

Enumerator:

  ALL |
  NONE |
  LIST |

Definition at line 75 of file ExceptionSvc.h.

    00075 { ALL, NONE, LIST };

enum ExceptionSvc::ReturnState`[private]`

Enumerator:

  DEFAULT |
  SUCCESS | Normal successful completion.
  FAILURE |
  RECOVERABLE |
  RETHROW |

Definition at line 76 of file ExceptionSvc.h.

    00076 { DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW };

## Constructor & Destructor Documentation

ExceptionSvc::ExceptionSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc |
| ) |  |  |

standard constructor

Parameters:

  | name | service instance name
  | pSvc | pointer to Service Locator

Definition at line 31 of file ExceptionSvc.cpp.

    00032   : Service( name, svc )
    00033   , m_mode_s ( "all" )
    00034   , m_algs_v (       )
    00035 {
    00036   declareProperty( "Catch"      , m_mode_s ) ;
    00037   declareProperty( "Algorithms" , m_algs_v ) ;
    00038 }

ExceptionSvc::~ExceptionSvc | ( |  | ) | `[virtual]`

Destructor.

Definition at line 42 of file ExceptionSvc.cpp.

    00042                             {
    00043
    00044 }

ExceptionSvc::ExceptionSvc | ( |  | ) | `[private]`

no default constructor

ExceptionSvc::ExceptionSvc | ( | const ExceptionSvc & |  | ) | `[private]`

no copy constructor

## Member Function Documentation

StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o,
|  | const GaudiException & | e |
| ) |  |  | const`[virtual]`

Handle caught GaudiExceptions Handle caught exceptions.

Implements IExceptionSvc.

Definition at line 322 of file ExceptionSvc.cpp.

References GaudiException::code(), MSG::DEBUG, endreq(), StatusCode::FAILURE, LIST, INamedInterface::name(), name, NONE, StatusCode::RECOVERABLE, second, and StatusCode::SUCCESS.

    00324 {
    00325
    00326   MsgStream log( msgSvc(), name() );
    00327   log << MSG::DEBUG << "Handling GaudiExcept for " << alg.name() << endreq;
    00328
    00329   // Don't do anything
    00330   if (m_mode == NONE) {
    00331     return StatusCode::FAILURE;
    00332   }
    00333
    00334   // rethrow
    00335   if (m_mode == ALL) {
    00336     throw (exc);
    00337     return StatusCode::FAILURE;
    00338   }
    00339
    00340   assert(m_mode == LIST);
    00341
    00342   //  Not one of the requested algs
    00343   if (m_algs.find(alg.name()) == m_algs.end()) {
    00344     return StatusCode::FAILURE;
    00345   }
    00346
    00347   // Requested to do something with this alg
    00348   ReturnState iret = m_retCodes.find(alg.name())->second;
    00349
    00350   switch ( iret ) {
    00351   case DEFAULT:
    00352     return exc.code();
    00353   case SUCCESS:
    00354     return StatusCode::SUCCESS;
    00355   case FAILURE:
    00356     return StatusCode::FAILURE;
    00357   case RECOVERABLE:
    00358     return StatusCode::RECOVERABLE;
    00359   case RETHROW:
    00360     throw ( exc );
    00361   }
    00362
    00363   return StatusCode::FAILURE;
    00364
    00365 }

StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o,
|  | const std::exception & | e |
| ) |  |  | const`[virtual]`

Handle caught std::exceptions Handle caught exceptions.

Implements IExceptionSvc.

Definition at line 272 of file ExceptionSvc.cpp.

References MSG::DEBUG, endreq(), StatusCode::FAILURE, LIST, INamedInterface::name(), name, NONE, StatusCode::RECOVERABLE, second, and StatusCode::SUCCESS.

    00274 {
    00275   MsgStream log( msgSvc(), name() );
    00276
    00277   log << MSG::DEBUG << "Handling std:except for " << alg.name() << endreq;
    00278
    00279   // Don't do anything
    00280   if (m_mode == NONE) {
    00281     return StatusCode::FAILURE;
    00282   }
    00283
    00284   if (m_mode == ALL) {
    00285     throw ( exc );
    00286   }
    00287
    00288   assert (m_mode == LIST);
    00289
    00290   // Not one of the requested algs
    00291   if (m_algs.find(alg.name()) == m_algs.end()) {
    00292     return StatusCode::FAILURE;
    00293   }
    00294
    00295   // Requested to do something with this alg
    00296   ReturnState iret = m_retCodes.find(alg.name())->second;
    00297
    00298   switch ( iret ) {
    00299   case DEFAULT:
    00300     // there is no default
    00301     return StatusCode::FAILURE;
    00302     break;
    00303   case SUCCESS:
    00304     return StatusCode::SUCCESS;
    00305     break;
    00306   case FAILURE:
    00307     return StatusCode::FAILURE;
    00308     break;
    00309   case RECOVERABLE:
    00310     return StatusCode::RECOVERABLE;
    00311     break;
    00312   case RETHROW:
    00313     throw ( exc );
    00314   }
    00315
    00316   return StatusCode::FAILURE;
    00317
    00318 }

StatusCode ExceptionSvc::handle | ( | const INamedInterface & | o | ) | const`[virtual]`

Handle caught (unknown)exceptions Handle caught exceptions.

Implements IExceptionSvc.

Definition at line 227 of file ExceptionSvc.cpp.

References MSG::DEBUG, endreq(), StatusCode::FAILURE, LIST, INamedInterface::name(), name, NONE, StatusCode::RECOVERABLE, second, and StatusCode::SUCCESS.

    00228 {
    00229   MsgStream log( msgSvc(), name() );
    00230
    00231   log << MSG::DEBUG << "Handling unknown exception for " << alg.name() << endreq;
    00232
    00233   // Don't do anything
    00234   if (m_mode == NONE) {
    00235     return StatusCode::FAILURE;
    00236   }
    00237
    00238   if (m_mode == ALL) {
    00239     throw;
    00240   }
    00241
    00242   assert (m_mode == LIST);
    00243
    00244   // Not one of the requested algs
    00245   if (m_algs.find(alg.name()) == m_algs.end()) {
    00246     return StatusCode::FAILURE;
    00247   }
    00248
    00249   // Requested to do something with this alg
    00250   ReturnState iret = m_retCodes.find(alg.name())->second;
    00251
    00252   switch ( iret ) {
    00253   case DEFAULT:
    00254     // there is no default
    00255     return StatusCode::FAILURE;
    00256   case SUCCESS:
    00257     return StatusCode::SUCCESS;
    00258   case FAILURE:
    00259     return StatusCode::FAILURE;
    00260   case RECOVERABLE:
    00261     return StatusCode::RECOVERABLE;
    00262   case RETHROW:
    00263     throw;
    00264   }
    00265
    00266   return StatusCode::FAILURE;
    00267
    00268 }

StatusCode ExceptionSvc::handleErr | ( | const INamedInterface & | o,
|  | const StatusCode & | s |
| ) |  |  | const`[virtual]`

Handle errors Handle errors.

Implements IExceptionSvc.

Definition at line 181 of file ExceptionSvc.cpp.

References MSG::DEBUG, endreq(), StatusCode::FAILURE, LIST, INamedInterface::name(), name, NONE, StatusCode::RECOVERABLE, second, and StatusCode::SUCCESS.

    00183 {
    00184   MsgStream log( msgSvc(), name() );
    00185
    00186   log << MSG::DEBUG << "Handling Error " << alg.name() << endreq;
    00187
    00188   // Don't do anything
    00189   if (m_mode == NONE) {
    00190     return st;
    00191   }
    00192
    00193   if (m_mode == ALL) {
    00194     return StatusCode::FAILURE;
    00195   }
    00196
    00197   assert (m_mode == LIST);
    00198
    00199   // Not one of the requested algs
    00200   if (m_algs.find(alg.name()) == m_algs.end()) {
    00201     return st;
    00202   }
    00203
    00204   // Requested to do something with this alg
    00205   ReturnState iret = m_retCodes.find(alg.name())->second;
    00206
    00207   switch ( iret ) {
    00208   case DEFAULT:
    00209     // there is no default
    00210     return st;
    00211   case SUCCESS:
    00212     return StatusCode::SUCCESS;
    00213   case FAILURE:
    00214     return StatusCode::FAILURE;
    00215   case RECOVERABLE:
    00216     return StatusCode::RECOVERABLE;
    00217   case RETHROW:
    00218     return st;
    00219   }
    00220
    00221   return st;
    00222
    00223 }

StatusCode ExceptionSvc::initialize | ( |  | ) | `[virtual]`

initialize the service

Reimplemented from Service.

Definition at line 50 of file ExceptionSvc.cpp.

References ALL, MSG::DEBUG, DEFAULT, std::endl(), endreq(), std::basic_string< _CharT, _Traits, _Alloc >::erase(), MSG::ERROR, FAILURE, StatusCode::FAILURE, Service::initialize(), StatusCode::isFailure(), std::basic_string< _CharT, _Traits, _Alloc >::length(), LIST, m_algs, m_algs_v, m_mode, m_mode_s, m_retCodes, Service::m_state, Service::msgSvc(), Service::name(), NONE, std::basic_string< _CharT, _Traits, _Alloc >::npos, Gaudi::StateMachine::OFFLINE, RECOVERABLE, RETHROW, SUCCESS, PropertyWithValue< TYPE >::value(), and MSG::WARNING.

    00050                          {
    00051   MsgStream log( msgSvc(), name() );
    00052
    00053   StatusCode status = Service::initialize();
    00054
    00055   if ( status.isFailure() )  { return status ; }                  // RETURN
    00056
    00057   if (m_mode_s == "all" || m_mode_s == "All" || m_mode_s == "ALL") {
    00058     m_mode = ALL;
    00059   } else if (m_mode_s == "none" || m_mode_s == "None" ||
    00060              m_mode_s == "NONE") {
    00061     m_mode = NONE;
    00062   } else if (m_mode_s == "list" || m_mode_s == "List" ||
    00063              m_mode_s == "LIST") {
    00064     m_mode = LIST;
    00065   } else {
    00066     log << MSG::ERROR << "Unknown value for property \"State\". Must be"
    00067         << " one of \"all\", \"none\", or \"list\"" << endreq;
    00068     m_state = Gaudi::StateMachine::OFFLINE;
    00069     return StatusCode::FAILURE;
    00070   }
    00071
    00072   std::vector<std::string>::const_iterator itr;
    00073   for (itr = m_algs_v.value().begin(); itr != m_algs_v.value().end(); ++itr) {
    00074     std::string a = *itr;
    00075     std::string alg(a);
    00076     ReturnState ret(RETHROW);
    00077
    00078     std::string::size_type ieq = a.find("=");
    00079     if (ieq != std::string::npos) {
    00080       alg = a;
    00081       alg.erase(ieq,alg.length());
    00082       a.erase(0,ieq+1);
    00083
    00084       if ( a == "DEFAULT" ) {
    00085         ret = DEFAULT;
    00086       } else if ( a == "SUCCESS" ) {
    00087         log << MSG::WARNING << "Unusual custom error return code SUCCESS for"
    00088             << " Algorithm \"" << alg << "\"" <<endreq;
    00089         ret = SUCCESS;
    00090       } else if ( a == "FAILURE" ) {
    00091         ret = FAILURE;
    00092       } else if ( a == "RECOVERABLE" ) {
    00093         ret = RECOVERABLE;
    00094       } else if ( a == "RETHROW" ) {
    00095         ret = RETHROW;
    00096       } else {
    00097         log << MSG::ERROR << "In JobOpts: unknown return code \"" << a
    00098             << "\" for Algorithm " << alg << std::endl
    00099             << "Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW"
    00100             << endreq;
    00101         m_state = Gaudi::StateMachine::OFFLINE;
    00102         return StatusCode::FAILURE;
    00103       }
    00104     }
    00105
    00106     m_algs.insert( alg );
    00107     m_retCodes[alg] = ret;
    00108   }
    00109
    00110   if (m_algs.size() > 0 && m_mode != NONE) {
    00111     m_mode = LIST;
    00112
    00113     log << MSG::DEBUG << "Will catch exceptions thrown by: " << std::endl;
    00114     std::set<std::string>::const_iterator it;
    00115     for (it = m_algs.begin(); it != m_algs.end(); ++it) {
    00116       log << "            " << *it << "  action: ";
    00117
    00118       ReturnState ret = m_retCodes.find(*it)->second;
    00119
    00120       switch( ret ) {
    00121       case( DEFAULT ):
    00122         log << "DEFAULT";
    00123         break;
    00124       case( SUCCESS ):
    00125         log << "SUCCESS";
    00126         break;
    00127       case( FAILURE ):
    00128         log << "FAILURE";
    00129         break;
    00130       case( RECOVERABLE ):
    00131         log << "RECOVERABLE";
    00132         break;
    00133       case( RETHROW ):
    00134         log << "RETHROW";
    00135         break;
    00136       }
    00137
    00138       log << std::endl;
    00139     }
    00140     log << endreq;
    00141
    00142   }
    00143
    00144   return status;
    00145 }

StatusCode ExceptionSvc::finalize | ( |  | ) | `[virtual]`

finalize the service

Reimplemented from Service.

Definition at line 150 of file ExceptionSvc.cpp.

References Service::finalize(), Service::msgSvc(), and Service::name().

    00150                        {
    00151   MsgStream log( msgSvc(), name() );
    00152
    00153   StatusCode status = Service::finalize();
    00154
    00155   return status;
    00156 }

StatusCode ExceptionSvc::queryInterface | ( | const InterfaceID & | iid,
|  | void ** | ppvi |
| ) |  |  | `[virtual]`

query the interface

See also:
  IInterface

Reimplemented from Service.

Definition at line 162 of file ExceptionSvc.cpp.

References StatusCode::FAILURE, IExceptionSvc::interfaceID(), Service::queryInterface(), and StatusCode::SUCCESS.

    00164 {
    00165   // invalid placeholder
    00166   if ( 0 == ppvi ) { return StatusCode::FAILURE   ; }   // RETURN
    00167   // check the identidier
    00168   if ( IExceptionSvc::interfaceID().versionMatch( iid ) )
    00169   { *ppvi = static_cast<IExceptionSvc*>  ( this ) ; }  // OK !
    00170   else  // ask for base class
    00171   { return Service::queryInterface ( iid , ppvi ) ; }  // RETURN
    00172   // increment the reference counter
    00173   addRef() ;
    00174   //
    00175   return StatusCode::SUCCESS ;                        // RETURN
    00176 }

ExceptionSvc& ExceptionSvc::operator= | ( | const ExceptionSvc & |  | ) | `[private]`

no assignement

## Friends And Related Function Documentation

friend class SvcFactory< ExceptionSvc >`[friend]`

Definition at line 27 of file ExceptionSvc.h.

## Member Data Documentation

std::string ExceptionSvc::m_mode_s`[private]`

Definition at line 78 of file ExceptionSvc.h.

Referenced by initialize().

ExceptState ExceptionSvc::m_mode`[private]`

Definition at line 79 of file ExceptionSvc.h.

Referenced by initialize().

StringArrayProperty ExceptionSvc::m_algs_v`[private]`

Definition at line 80 of file ExceptionSvc.h.

Referenced by initialize().

std::set<std::string> ExceptionSvc::m_algs`[private]`

Definition at line 81 of file ExceptionSvc.h.

Referenced by initialize().

std::map<std::string,ReturnState> ExceptionSvc::m_retCodes`[private]`

Definition at line 82 of file ExceptionSvc.h.

Referenced by initialize().

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiSvc/v17r1/src/ExceptionSvc/ExceptionSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiSvc/v17r1/src/ExceptionSvc/ExceptionSvc.cpp