The Gaudi Framework  v31r0 (aeb156f0)
ExceptionSvc Class Reference

Simple implementation of IExceptionSvc abstract interface. More...

#include <src/ExceptionSvc.h>

Inheritance diagram for ExceptionSvc:
Collaboration diagram for ExceptionSvc:

Public Member Functions

StatusCode handle (const INamedInterface &o, const GaudiException &e) const override
 Handle caught GaudiExceptions. More...
 
StatusCode handle (const INamedInterface &o, const std::exception &e) const override
 Handle caught std::exceptions. More...
 
StatusCode handle (const INamedInterface &o) const override
 Handle caught (unknown)exceptions. More...
 
StatusCode handleErr (const INamedInterface &o, const StatusCode &s) const override
 Handle errors. More...
 
StatusCode initialize () override
 initialize the service More...
 
- Public Member Functions inherited from extends< Service, IExceptionSvc >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Private Types

enum  Policy { ALL, NONE }
 
enum  ReturnState {
  SUCCESS, FAILURE, RECOVERABLE, RETHROW,
  DEFAULT
}
 

Private Member Functions

 ExceptionSvc ()=delete
 no default constructor More...
 
 ExceptionSvc (const ExceptionSvc &)=delete
 
ExceptionSvcoperator= (const ExceptionSvc &)=delete
 
virtual StatusCode process (const INamedInterface &o) const
 

Private Attributes

Policy m_mode_exc = ALL
 
Policy m_mode_err = NONE
 
std::map< std::string, ReturnStatem_retCodesExc
 
std::map< std::string, ReturnStatem_retCodesErr
 
Gaudi::Property< std::stringm_mode_exc_s {this, "Catch", "ALL"}
 
Gaudi::Property< std::stringm_mode_err_s {this, "Errors", "NONE"}
 

Additional Inherited Members

- Public Types inherited from extends< Service, IExceptionSvc >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Detailed Description

Simple implementation of IExceptionSvc abstract interface.

Author
(1) ATLAS collaboration
(2) modified by Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2007-03-08

Definition at line 19 of file ExceptionSvc.h.

Member Enumeration Documentation

enum ExceptionSvc::Policy
private
Enumerator
ALL 
NONE 

Definition at line 47 of file ExceptionSvc.h.

Enumerator
SUCCESS 
FAILURE 
RECOVERABLE 
RETHROW 
DEFAULT 

Definition at line 48 of file ExceptionSvc.h.

Constructor & Destructor Documentation

ExceptionSvc::ExceptionSvc ( )
privatedelete

no default constructor

ExceptionSvc::ExceptionSvc ( const ExceptionSvc )
privatedelete

Member Function Documentation

StatusCode ExceptionSvc::handle ( const INamedInterface o,
const GaudiException e 
) const
override

Handle caught GaudiExceptions.

Handle caught exceptions

Definition at line 208 of file ExceptionSvc.cpp.

208  {
209  if ( msgLevel( MSG::DEBUG ) ) debug() << "Handling GaudiException: \"" << exc << "\" for " << alg.name() << endmsg;
210  return process( alg );
211 }
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
virtual StatusCode process(const INamedInterface &o) const
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
StatusCode ExceptionSvc::handle ( const INamedInterface o,
const std::exception e 
) const
override

Handle caught std::exceptions.

Handle caught exceptions

Definition at line 202 of file ExceptionSvc.cpp.

202  {
203  if ( msgLevel( MSG::DEBUG ) ) debug() << "Handling std:except: \"" << exc.what() << "\" for " << alg.name() << endmsg;
204  return process( alg );
205 }
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
virtual StatusCode process(const INamedInterface &o) const
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
StatusCode ExceptionSvc::handle ( const INamedInterface o) const
override

Handle caught (unknown)exceptions.

Handle caught exceptions

Definition at line 196 of file ExceptionSvc.cpp.

196  {
197  if ( msgLevel( MSG::DEBUG ) ) debug() << "Handling unknown exception for " << alg.name() << endmsg;
198  return process( alg );
199 }
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
virtual StatusCode process(const INamedInterface &o) const
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
StatusCode ExceptionSvc::handleErr ( const INamedInterface o,
const StatusCode s 
) const
override

Handle errors.

Handle errors

Definition at line 139 of file ExceptionSvc.cpp.

139  {
140  if ( msgLevel( MSG::DEBUG ) ) debug() << "Handling Error from " << alg.name() << endmsg;
141 
142  // is this Alg special?
143  auto i = m_retCodesErr.find( alg.name() );
144  if ( i != m_retCodesErr.end() ) {
145  switch ( i->second ) {
146  case SUCCESS:
147  return StatusCode::SUCCESS;
148  case FAILURE:
149  return StatusCode::FAILURE;
150  case RECOVERABLE:
152  // should never get here
153  case RETHROW:
154  break;
155  case DEFAULT:
156  break;
157  }
158 
159  } else {
160 
161  if ( m_mode_err == ALL ) return StatusCode::FAILURE; // turn it into FAILURE
162  assert( m_mode_err == NONE );
163  // don't touch the return code
164  return st;
165  }
166  return StatusCode::FAILURE;
167 }
constexpr static const auto RECOVERABLE
Definition: StatusCode.h:87
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
T end(T...args)
T find(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
std::map< std::string, ReturnState > m_retCodesErr
Definition: ExceptionSvc.h:51
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Policy m_mode_err
Definition: ExceptionSvc.h:50
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
StatusCode ExceptionSvc::initialize ( )
override

initialize the service

Definition at line 30 of file ExceptionSvc.cpp.

30  {
32  if ( status.isFailure() ) { return status; }
33 
34  string key = m_mode_exc_s.value();
35 
36  auto loc = key.find( " " );
37  std::string mode = key.substr( 0, loc );
38 
39  toupper( mode );
40 
41  if ( mode == "NONE" ) {
42  m_mode_exc = NONE;
43  } else if ( mode == "ALL" ) {
44  m_mode_exc = ALL;
45  } else {
46  error() << "Unknown mode for Exception handling: \"" << mode << "\". Default must be one of \"ALL\" or \"NONE\""
47  << endmsg;
49  return StatusCode::FAILURE;
50  }
51 
52  if ( loc == string::npos ) {
53  key.clear();
54  } else {
55  key = key.substr( loc + 1 );
56  }
57 
58  std::string VAL, TAG;
59 
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];
65  toupper( VAL );
66 
67  if ( VAL == "SUCCESS" ) {
68  m_retCodesExc[TAG] = SUCCESS;
69  } else if ( VAL == "FAILURE" ) {
70  m_retCodesExc[TAG] = FAILURE;
71  } else if ( VAL == "REVOVERABLE" ) {
73  } else if ( VAL == "RETHROW" ) {
74  m_retCodesExc[TAG] = RETHROW;
75  } else if ( VAL == "DEFAULT" ) {
76  m_retCodesExc[TAG] = DEFAULT;
77  } else {
78  error() << "In JobOpts: unknown return code \"" << VAL << "\" for Algorithm " << TAG << std::endl
79  << " Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW" << endmsg;
81  return StatusCode::FAILURE;
82  }
83 
84  if ( msgLevel( MSG::DEBUG ) )
85  debug() << "Will catch exceptions thrown by: " << TAG << " -> action: " << VAL << endmsg;
86  }
87 
88  // now process errors
89  key = m_mode_err_s.value();
90 
91  loc = key.find( " " );
92  mode = key.substr( 0, loc );
93 
94  toupper( mode );
95 
96  if ( mode == "NONE" ) {
97  m_mode_err = NONE;
98  } else if ( mode == "ALL" ) {
99  m_mode_err = ALL;
100  } else {
101  error() << "Unknown mode for Error handling: \"" << mode << "\". Default must be one of \"ALL\" or \"NONE\""
102  << endmsg;
104  return StatusCode::FAILURE;
105  }
106 
107  if ( loc == string::npos ) {
108  key.clear();
109  } else {
110  key = key.substr( loc + 1 );
111  }
112 
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];
116  toupper( VAL );
117 
118  if ( VAL == "SUCCESS" ) {
119  m_retCodesErr[TAG] = SUCCESS;
120  } else if ( VAL == "FAILURE" ) {
121  m_retCodesErr[TAG] = FAILURE;
122  } else if ( VAL == "RECOVERABLE" ) {
123  m_retCodesErr[TAG] = RECOVERABLE;
124  } else {
125  error() << "In JobOpts: unknown return code \"" << VAL << "\" for Algorithm " << TAG << std::endl
126  << " Must be one of: SUCCESS, FAILURE, RECOVERABLE" << endmsg;
128  return StatusCode::FAILURE;
129  }
130 
131  if ( msgLevel( MSG::DEBUG ) )
132  debug() << "Will process Errors returned by: " << TAG << " -> action: " << VAL << endmsg;
133  }
134  return status;
135 }
StatusCode initialize() override
Definition: Service.cpp:60
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:153
T exp(T...args)
T endl(T...args)
Gaudi::Property< std::string > m_mode_err_s
Definition: ExceptionSvc.h:54
Policy m_mode_exc
Definition: ExceptionSvc.h:50
bool isFailure() const
Definition: StatusCode.h:130
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
T clear(T...args)
std::map< std::string, ReturnState > m_retCodesExc
Definition: ExceptionSvc.h:51
T find(T...args)
Gaudi::Property< std::string > m_mode_exc_s
Definition: ExceptionSvc.h:53
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
std::map< std::string, ReturnState > m_retCodesErr
Definition: ExceptionSvc.h:51
constexpr static const auto FAILURE
Definition: StatusCode.h:86
T substr(T...args)
Policy m_mode_err
Definition: ExceptionSvc.h:50
AttribStringParser::Iterator begin(const AttribStringParser &parser)
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
ExceptionSvc& ExceptionSvc::operator= ( const ExceptionSvc )
privatedelete
StatusCode ExceptionSvc::process ( const INamedInterface o) const
privatevirtual

Definition at line 170 of file ExceptionSvc.cpp.

170  {
171 
172  // is this Alg special?
173  auto i = m_retCodesExc.find( alg.name() );
174  if ( i != m_retCodesExc.end() ) {
175 
176  switch ( i->second ) {
177  case DEFAULT:
178  return StatusCode::FAILURE; // there is no default
179  case SUCCESS:
180  return StatusCode::SUCCESS;
181  case FAILURE:
182  return StatusCode::FAILURE;
183  case RECOVERABLE:
185  case RETHROW:
186  throw;
187  }
188  }
189 
190  if ( m_mode_exc == ALL ) { throw; }
191  assert( m_mode_exc == NONE );
192  return StatusCode::FAILURE;
193 }
constexpr static const auto RECOVERABLE
Definition: StatusCode.h:87
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
T end(T...args)
Policy m_mode_exc
Definition: ExceptionSvc.h:50
std::map< std::string, ReturnState > m_retCodesExc
Definition: ExceptionSvc.h:51
T find(T...args)
constexpr static const auto FAILURE
Definition: StatusCode.h:86

Member Data Documentation

Policy ExceptionSvc::m_mode_err = NONE
private

Definition at line 50 of file ExceptionSvc.h.

Gaudi::Property<std::string> ExceptionSvc::m_mode_err_s {this, "Errors", "NONE"}
private

Definition at line 54 of file ExceptionSvc.h.

Policy ExceptionSvc::m_mode_exc = ALL
private

Definition at line 50 of file ExceptionSvc.h.

Gaudi::Property<std::string> ExceptionSvc::m_mode_exc_s {this, "Catch", "ALL"}
private

Definition at line 53 of file ExceptionSvc.h.

std::map<std::string, ReturnState> ExceptionSvc::m_retCodesErr
private

Definition at line 51 of file ExceptionSvc.h.

std::map<std::string, ReturnState> ExceptionSvc::m_retCodesExc
private

Definition at line 51 of file ExceptionSvc.h.


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