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"
41 , m_errorPolicy ( "GSL" )
42 , m_handlersTypeNames ()
46 declareProperty(
"ErrorPolicy" , m_errorPolicy ) ;
47 declareProperty(
"Handlers" , m_handlersTypeNames ) ;
48 declareProperty(
"IgnoreCodes" , m_ignore ) ;
72 <<
" Error in initialization of base class 'Service'"<<
endmsg;
80 { gsl_set_error_handler_off() ; }
82 { gsl_set_error_handler ( 0 ) ; }
92 <<
" Valid policies: "
93 <<
"[ 'GSL' , 'Off' , 'Abort' , 'Ignore' , 'Exception' , 'Handle' ]"
100 gsl_set_error_handler( handler );
103 <<
" GSL Error Handler is '"
119 std::string::const_iterator ipos =
120 std::find( it->begin() , it->end() ,
'/');
121 const std::string::size_type pos = ipos - it->begin() ;
123 if( it->end() != ipos )
125 ( std::string( *it , 0 , pos ) ,
126 std::string( *it , pos + 1, it->length() ), eh ,
this ) ; }
129 ( *it , std::string( *it , pos + 1, it->length() ) ,
133 <<
" Could not retrieve tool '" << *it <<
"'"<<
endmsg ;
137 <<
" Could not retrieve tool '" << *it <<
"'"<<
endmsg ;
175 gsl_set_error_handler( hh );
189 gsl_set_error_handler( handler );
192 log <<
MSG::DEBUG <<
" New GSL handler is set '" ;
193 if( 0 == handler ) { log <<
"NULL" ; }
227 if( m_ignore.end() != std::find( m_ignore.begin () ,
229 error.
code ) ) {
return sc ; }
231 for( Handlers::const_iterator handler = m_handlers.begin() ;
232 sc.
isSuccess() && m_handlers.end() != handler ; ++handler )
233 { sc = (*handler)->handle( error ); }
The abstract interface for arbitrary GSL error handler.
Definition of the MsgStream class used to transmit messages.
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.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode initialize()
standard service initialization
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
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
virtual ~GslSvc()
destructor, virtual and protected
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.
virtual const std::string & name() const
Retrieve name of the service.
std::string m_errorPolicy
error policy
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
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.
bool isValid() const
Allow for check if smart pointer is valid.
GAUDI_API void ignoreTheError(const char *reason, const char *file, int line, int code)
The simplest Gsl Error handler, It simply ingnores the error.
Templated class to add the standard messaging functionalities.
static const IGslSvc * setGslSvc(const IGslSvc *value)
set new value for static Gaudi GSL Service
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.
virtual StatusCode finalize()
standard service finalization
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
virtual StatusCode status(const int error) const
transform GSL error code to Gaudi status code