boost::execution_monitor uniformly detects and reports the occurrence of several types of signals and exceptions, reducing various errors to a uniform boost::execution_exception which is returned to a caller.
class execution_monitor { public: virtual ~execution_monitor(); template<typename Exception, typename ExceptionTranslator> void register_exception_translator( ExceptionTranslator const& tr, boost::type<Exception>* = 0 ); int execute( unit_test::callback0<int> const& F, bool catch_system_errors = true, int timeout = 0 ); }; // exception monitor
Supplied cause this class intended to be used polymorphically.
Use this template member function to register translator for any custom exceptions types of your choice. Translators gets chained, so you could register as many as you want. Translator function of functor should accept single parameter - const reference to the instance of the class Exception. The return value is ignored. An example usage is like this:
the_monitor.register_exception_translator<my_exception1>( translate_my_exception1 )
Effects:
Calls the zero arity function F inside a try/catch block which may also include other unspecified platform dependent error detection code. Throws boost::execution_exception on an uncaught C++ exception, timeout alarm and, if catch_system_errors flag is true, a hardware or software signal, trap, or other exception. If catch_system_errors flag is false program will crash in case of system level error occur. execution_monitor::execute() doesn't consider it an error for the function F to return a non-zero value.
Returns:
The integer value returned by the function F.