3 #include "GaudiKernel/MsgStream.h"
4 #include "GaudiKernel/System.h"
5 #include "GaudiKernel/ISvcLocator.h"
6 #include "GaudiKernel/IToolSvc.h"
11 #include "GaudiGSL/IGslErrorHandler.h"
12 #include "GaudiGSL/GslError.h"
14 #include "GaudiGSL/GaudiGSL.h"
16 #include "GaudiGSL/GslErrorHandlers.h"
18 #include "gsl/gsl_errno.h"
42 declareProperty(
"ErrorPolicy" , m_errorPolicy ) ;
43 declareProperty(
"Handlers" , m_handlersTypeNames ) ;
44 declareProperty(
"IgnoreCodes" , m_ignore ) ;
63 <<
" Error in initialization of base class 'Service'"<<
endmsg;
71 { gsl_set_error_handler_off() ; }
73 { gsl_set_error_handler ( 0 ) ; }
83 <<
" Valid policies: "
84 <<
"[ 'GSL' , 'Off' , 'Abort' , 'Ignore' , 'Exception' , 'Handle' ]"
90 GslErrorHandler
handler = gsl_set_error_handler(
nullptr );
91 gsl_set_error_handler( handler );
94 <<
" GSL Error Handler is '"
102 auto toolsvc = serviceLocator()->service<
IToolSvc>(
"ToolSvc");
109 auto pos = it.find(
'/');
111 if( pos != std::string::npos ) {
112 sc = toolsvc->retrieveTool
113 ( it.substr( 0 , pos ), it.substr( pos + 1 ), eh , this ) ;
115 sc = toolsvc->retrieveTool( it , it , eh ,
this ) ;
119 <<
" Could not retrieve tool '" << it <<
"'"<<
endmsg ;
123 <<
" Could not retrieve tool '" << it <<
"'"<<
endmsg ;
160 GslErrorHandler hh = gsl_set_error_handler(
nullptr );
161 gsl_set_error_handler( hh );
175 gsl_set_error_handler( handler );
178 log <<
MSG::DEBUG <<
" New GSL handler is set '" ;
179 if( !handler ) { log <<
"NULL" ; }
213 if( m_ignore.end() != std::find( m_ignore.begin () ,
215 error.
code ) ) {
return sc ; }
217 for(
auto handler = m_handlers.begin() ;
218 sc.
isSuccess() && m_handlers.end() != handler ; ++handler )
219 { sc = (*handler)->handle( error ); }
The abstract interface for arbitrary GSL error handler.
Definition of the MsgStream class used to transmit messages.
StatusCode initialize() override
virtual StatusCode handle(const GslError &error) const
handle the GSL error
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Helper class to represent GSL errors.
StatusCode finalize() override
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode initialize()
standard service initialization
bool isSuccess() const
Test for a status code of SUCCESS.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
void(* GslErrorHandler)(const char *, const char *, int, int)
type definition of "standard" GSL error handler functions
Names m_handlersTypeNames
bool isFailure() const
Test for a status code of FAILURE.
virtual GslErrorHandler handler() const
retrieve the current GSL error handler
#define DECLARE_COMPONENT(type)
This class is used for returning status codes from appropriate routines.
GAUDI_API void throwException(const char *reason, const char *file, int line, int code)
The simple Gsl Error handler, it throwns the Gaudi Exception.
The implementation of IGslSvc interface.
std::string m_errorPolicy
error policy
virtual GslErrorHandler setHandler(GslErrorHandler handler) const
set new GSL error handler
GAUDI_API void handleTheError(const char *reason, const char *file, int line, int code)
The simplest Gsl Error handler, It delegates the actual error handling to GSL Service.
Base class used to extend a class implementing other interfaces.
GAUDI_API void ignoreTheError(const char *reason, const char *file, int line, int code)
The simplest Gsl Error handler, It simply ingnores the error.
static const IGslSvc * setGslSvc(const IGslSvc *value)
set new value for static Gaudi GSL Service
virtual StatusCode finalize()
standard service finalization
virtual StatusCode status(const int error) const
transform GSL error code to Gaudi status code