The Gaudi Framework  master (594c33fa)
ExceptionSvc Class Reference

#include </builds/gaudi/Gaudi/GaudiMonitor/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...
 
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 >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
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 std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view 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 (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 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...
 

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
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 Standard Destructor
More...
 
int outputLevel () const
 get the Service's output level More...
 
- 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" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
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()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
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 29 of file ExceptionSvc.h.

Member Enumeration Documentation

◆ Policy

enum ExceptionSvc::Policy
private
Enumerator
ALL 
NONE 

Definition at line 57 of file ExceptionSvc.h.

57 { ALL, NONE };

◆ ReturnState

Enumerator
SUCCESS 
FAILURE 
RECOVERABLE 
RETHROW 
DEFAULT 

Definition at line 58 of file ExceptionSvc.h.

Constructor & Destructor Documentation

◆ ExceptionSvc() [1/2]

ExceptionSvc::ExceptionSvc ( )
privatedelete

no default constructor

◆ ExceptionSvc() [2/2]

ExceptionSvc::ExceptionSvc ( const ExceptionSvc )
privatedelete

Member Function Documentation

◆ handle() [1/3]

StatusCode ExceptionSvc::handle ( const INamedInterface o) const
override

Handle caught (unknown)exceptions.

Handle caught exceptions

Definition at line 206 of file ExceptionSvc.cpp.

206  {
207  if ( msgLevel( MSG::DEBUG ) ) debug() << "Handling unknown exception for " << alg.name() << endmsg;
208  return process( alg );
209 }

◆ handle() [2/3]

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

Handle caught GaudiExceptions.

Handle caught exceptions

Definition at line 218 of file ExceptionSvc.cpp.

218  {
219  if ( msgLevel( MSG::DEBUG ) ) debug() << "Handling GaudiException: \"" << exc << "\" for " << alg.name() << endmsg;
220  return process( alg );
221 }

◆ handle() [3/3]

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

Handle caught std::exceptions.

Handle caught exceptions

Definition at line 212 of file ExceptionSvc.cpp.

212  {
213  if ( msgLevel( MSG::DEBUG ) ) debug() << "Handling std:except: \"" << exc.what() << "\" for " << alg.name() << endmsg;
214  return process( alg );
215 }

◆ handleErr()

StatusCode ExceptionSvc::handleErr ( const INamedInterface o,
const StatusCode s 
) const
override

Handle errors.

Handle errors

Definition at line 149 of file ExceptionSvc.cpp.

149  {
150  if ( msgLevel( MSG::DEBUG ) ) debug() << "Handling Error from " << alg.name() << endmsg;
151 
152  // is this Alg special?
153  auto i = m_retCodesErr.find( alg.name() );
154  if ( i != m_retCodesErr.end() ) {
155  switch ( i->second ) {
156  case SUCCESS:
157  return StatusCode::SUCCESS;
158  case FAILURE:
159  return StatusCode::FAILURE;
160  case RECOVERABLE:
162  // should never get here
163  case RETHROW:
164  break;
165  case DEFAULT:
166  break;
167  }
168 
169  } else {
170 
171  if ( m_mode_err == ALL ) return StatusCode::FAILURE; // turn it into FAILURE
172  assert( m_mode_err == NONE );
173  // don't touch the return code
174  return st;
175  }
176  return StatusCode::FAILURE;
177 }

◆ initialize()

StatusCode ExceptionSvc::initialize ( )
override

initialize the service

Definition at line 40 of file ExceptionSvc.cpp.

40  {
42  if ( status.isFailure() ) { return status; }
43 
44  string key = m_mode_exc_s.value();
45 
46  auto loc = key.find( " " );
47  std::string mode = key.substr( 0, loc );
48 
49  toupper( mode );
50 
51  if ( mode == "NONE" ) {
52  m_mode_exc = NONE;
53  } else if ( mode == "ALL" ) {
54  m_mode_exc = ALL;
55  } else {
56  error() << "Unknown mode for Exception handling: \"" << mode << "\". Default must be one of \"ALL\" or \"NONE\""
57  << endmsg;
59  return StatusCode::FAILURE;
60  }
61 
62  if ( loc == string::npos ) {
63  key.clear();
64  } else {
65  key = key.substr( loc + 1 );
66  }
67 
68  std::string VAL, TAG;
69 
70  static const boost::regex exp{ "[[:space:]]*([^[:space:]]+)[[:space:]]*=[[:space:]]*([^[:space:]]+)" };
71  static const auto tok_end = boost::sregex_iterator();
72  for ( auto tok_iter = boost::sregex_iterator( begin( key ), end( key ), exp ); tok_iter != tok_end; ++tok_iter ) {
73  TAG = ( *tok_iter )[1];
74  VAL = ( *tok_iter )[2];
75  toupper( VAL );
76 
77  if ( VAL == "SUCCESS" ) {
78  m_retCodesExc[TAG] = SUCCESS;
79  } else if ( VAL == "FAILURE" ) {
80  m_retCodesExc[TAG] = FAILURE;
81  } else if ( VAL == "REVOVERABLE" ) {
83  } else if ( VAL == "RETHROW" ) {
84  m_retCodesExc[TAG] = RETHROW;
85  } else if ( VAL == "DEFAULT" ) {
86  m_retCodesExc[TAG] = DEFAULT;
87  } else {
88  error() << "In JobOpts: unknown return code \"" << VAL << "\" for Algorithm " << TAG << std::endl
89  << " Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW" << endmsg;
91  return StatusCode::FAILURE;
92  }
93 
94  if ( msgLevel( MSG::DEBUG ) )
95  debug() << "Will catch exceptions thrown by: " << TAG << " -> action: " << VAL << endmsg;
96  }
97 
98  // now process errors
100 
101  loc = key.find( " " );
102  mode = key.substr( 0, loc );
103 
104  toupper( mode );
105 
106  if ( mode == "NONE" ) {
107  m_mode_err = NONE;
108  } else if ( mode == "ALL" ) {
109  m_mode_err = ALL;
110  } else {
111  error() << "Unknown mode for Error handling: \"" << mode << "\". Default must be one of \"ALL\" or \"NONE\""
112  << endmsg;
114  return StatusCode::FAILURE;
115  }
116 
117  if ( loc == string::npos ) {
118  key.clear();
119  } else {
120  key = key.substr( loc + 1 );
121  }
122 
123  for ( auto tok_iter = boost::sregex_iterator( begin( key ), end( key ), exp ); tok_iter != tok_end; ++tok_iter ) {
124  TAG = ( *tok_iter )[1];
125  VAL = ( *tok_iter )[2];
126  toupper( VAL );
127 
128  if ( VAL == "SUCCESS" ) {
129  m_retCodesErr[TAG] = SUCCESS;
130  } else if ( VAL == "FAILURE" ) {
131  m_retCodesErr[TAG] = FAILURE;
132  } else if ( VAL == "RECOVERABLE" ) {
133  m_retCodesErr[TAG] = RECOVERABLE;
134  } else {
135  error() << "In JobOpts: unknown return code \"" << VAL << "\" for Algorithm " << TAG << std::endl
136  << " Must be one of: SUCCESS, FAILURE, RECOVERABLE" << endmsg;
138  return StatusCode::FAILURE;
139  }
140 
141  if ( msgLevel( MSG::DEBUG ) )
142  debug() << "Will process Errors returned by: " << TAG << " -> action: " << VAL << endmsg;
143  }
144  return status;
145 }

◆ operator=()

ExceptionSvc& ExceptionSvc::operator= ( const ExceptionSvc )
privatedelete

◆ process()

StatusCode ExceptionSvc::process ( const INamedInterface o) const
privatevirtual

Definition at line 180 of file ExceptionSvc.cpp.

180  {
181 
182  // is this Alg special?
183  auto i = m_retCodesExc.find( alg.name() );
184  if ( i != m_retCodesExc.end() ) {
185 
186  switch ( i->second ) {
187  case DEFAULT:
188  return StatusCode::FAILURE; // there is no default
189  case SUCCESS:
190  return StatusCode::SUCCESS;
191  case FAILURE:
192  return StatusCode::FAILURE;
193  case RECOVERABLE:
195  case RETHROW:
196  throw;
197  }
198  }
199 
200  if ( m_mode_exc == ALL ) { throw; }
201  assert( m_mode_exc == NONE );
202  return StatusCode::FAILURE;
203 }

Member Data Documentation

◆ m_mode_err

Policy ExceptionSvc::m_mode_err = NONE
private

Definition at line 60 of file ExceptionSvc.h.

◆ m_mode_err_s

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

Definition at line 64 of file ExceptionSvc.h.

◆ m_mode_exc

Policy ExceptionSvc::m_mode_exc = ALL
private

Definition at line 60 of file ExceptionSvc.h.

◆ m_mode_exc_s

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

Definition at line 63 of file ExceptionSvc.h.

◆ m_retCodesErr

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

Definition at line 61 of file ExceptionSvc.h.

◆ m_retCodesExc

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

Definition at line 61 of file ExceptionSvc.h.


The documentation for this class was generated from the following files:
ExceptionSvc::process
virtual StatusCode process(const INamedInterface &o) const
Definition: ExceptionSvc.cpp:180
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
toupper
void toupper(std::string &s)
Definition: ExceptionSvc.cpp:36
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
std::string
STL class.
ExceptionSvc::m_mode_exc
Policy m_mode_exc
Definition: ExceptionSvc.h:60
Service::m_state
Gaudi::StateMachine::State m_state
Service state
Definition: Service.h:200
std::map::find
T find(T... args)
ExceptionSvc::RETHROW
@ RETHROW
Definition: ExceptionSvc.h:58
ExceptionSvc::m_mode_err
Policy m_mode_err
Definition: ExceptionSvc.h:60
ExceptionSvc::m_retCodesErr
std::map< std::string, ReturnState > m_retCodesErr
Definition: ExceptionSvc.h:61
ExceptionSvc::RECOVERABLE
@ RECOVERABLE
Definition: ExceptionSvc.h:58
CommonMessaging< implements< IService, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:148
ExceptionSvc::m_retCodesExc
std::map< std::string, ReturnState > m_retCodesExc
Definition: ExceptionSvc.h:61
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:81
StatusCode
Definition: StatusCode.h:65
ExceptionSvc::ALL
@ ALL
Definition: ExceptionSvc.h:57
CLHEP::begin
double * begin(CLHEP::HepVector &v)
Definition: TupleAlg.cpp:45
Gaudi::StateMachine::OFFLINE
@ OFFLINE
Definition: StateMachine.h:23
ExceptionSvc::SUCCESS
@ SUCCESS
Definition: ExceptionSvc.h:58
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:239
ExceptionSvc::DEFAULT
@ DEFAULT
Definition: ExceptionSvc.h:58
ExceptionSvc::NONE
@ NONE
Definition: ExceptionSvc.h:57
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
ExceptionSvc::m_mode_err_s
Gaudi::Property< std::string > m_mode_err_s
Definition: ExceptionSvc.h:64
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
std::endl
T endl(T... args)
std::exp
T exp(T... args)
std::map::end
T end(T... args)
IOTest.end
end
Definition: IOTest.py:125
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
StatusCode::RECOVERABLE
constexpr static const auto RECOVERABLE
Definition: StatusCode.h:102
ProduceConsume.key
key
Definition: ProduceConsume.py:81
ExceptionSvc::m_mode_exc_s
Gaudi::Property< std::string > m_mode_exc_s
Definition: ExceptionSvc.h:63
ExceptionSvc::FAILURE
@ FAILURE
Definition: ExceptionSvc.h:58