[1.55b1][coroutine][exception] not propagating exception type
I'm on VS2013, with BOOST_COROUTINES_V1 defined. I've merged
boost::coroutine's exception test with boost::exception's
derives_std_exception test. A std::exception& is caught when based on
docs I would expect derives_std_exception to be caught. Am I doing
something obviously wrong?
Thanks, Jeff
#include
2013/10/29 Jeff Flinn
I'm on VS2013, with BOOST_COROUTINES_V1 defined. I've merged boost::coroutine's exception test with boost::exception's derives_std_exception test. A std::exception& is caught when based on docs I would expect derives_std_exception to be caught. Am I doing something obviously wrong?
coroutine uses boost::exception_ptr in order to transport exceptions - it tries to get the type nearest to the exception type. you could try: boost::throw_exception(boost::enable_current_exception(e)); instead of throw e;
On Tue, Oct 29, 2013 at 12:00 PM, Jeff Flinn
template< typename E > void f14(coro_void_void::caller_type & , E const& e) { throw e; }
I haven't checked but if boost::exception_ptr is used to transport this exception to another thread, then you should call boost::throw_exception instead of using throw directly. -- Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
On 10/29/2013 3:20 PM, Emil Dotchevski wrote:
On Tue, Oct 29, 2013 at 12:00 PM, Jeff Flinn
wrote: template< typename E > void f14(coro_void_void::caller_type & , E const& e) { throw e; }
I haven't checked but if boost::exception_ptr is used to transport this exception to another thread, then you should call boost::throw_exception instead of using throw directly.
Indeed! template< typename E > void f14(coro_void_void::caller_type & , E const& e) { boost::throw_exception(e); } works as expected. Oliver suggested: boost::throw_exception(boost::enable_current_exception(e)); As the previous gives me the expected behavior(at least on the surface), I'm not sure what this latter provides even after a quick read of the docs. Thanks, Jeff
On Tue, Oct 29, 2013 at 12:46 PM, Jeff Flinn
Oliver suggested:
boost::throw_exception(boost::enable_current_exception(e));
If you use boost::throw_exception to throw, enable_current_exception is redundant. -- Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
participants (3)
-
Emil Dotchevski
-
Jeff Flinn
-
Oliver Kowalke