[coroutine] - only std exceptions are caught from coroutines
2016-02-19 17:14 GMT+01:00
Hi,
I use boost coroutines and I have realized that in my environment (Visual Studio 2015 Update 1, x64) I cannot catch the exception type of a custom exception.
The example below demonstrates the case. I have a custom exception derived from a std::runime_error. In the main function I want to catch my custom exception type that was thrown in the coroutine. However somehow I always end up in the catch branch of the std::runtime_error.
Are custom exceptions are not supported by the coroutines library?
boost.coroutine - no (->boost.exception's exception_ptr) but if you use boost.coroutine2 (C++11), the exception will be catched by 'catch (MyException const&)' clause
On Fri, Feb 19, 2016 at 8:14 AM,
Hi,
I use boost coroutines and I have realized that in my environment (Visual Studio 2015 Update 1, x64) I cannot catch the exception type of a custom exception.
The example below demonstrates the case. I have a custom exception derived from a std::runime_error. In the main function I want to catch my custom exception type that was thrown in the coroutine. However somehow I always end up in the catch branch of the std::runtime_error.
Are custom exceptions are not supported by the coroutines library?
boost::exception_ptr requires that the exception is thrown using enable_current_exception, see www.boost.org/doc/libs/release/libs/exception/doc/enable_current_exception.html. I recommend to throw the exception using BOOST_THROW_EXCEPTION, which internally uses enable_current_exception. Emil
2016-02-19 22:10 GMT+01:00 Emil Dotchevski
boost::exception_ptr requires that the exception is thrown using enable_current_exception, see www.boost.org/doc/libs/release/libs/exception/doc/enable_current_exception.html. I recommend to throw the exception using BOOST_THROW_EXCEPTION, which internally uses enable_current_exception.
the code looks like this boost::exception_ptr except_; ... if ( except_) boost::rethrow_exception( except_);
On Sat, Feb 20, 2016 at 2:44 AM, Oliver Kowalke
2016-02-19 22:10 GMT+01:00 Emil Dotchevski
: boost::exception_ptr requires that the exception is thrown using enable_current_exception, see www.boost.org/doc/libs/release/libs/exception/doc/enable_current_exception.html. I recommend to throw the exception using BOOST_THROW_EXCEPTION, which internally uses enable_current_exception.
the code looks like this
boost::exception_ptr except_; ... if ( except_) boost::rethrow_exception( except_);
I mean the original exception emitted by the coroutine should be thrown using BOOST_THROW_EXCEPTION. Emil
participants (3)
-
Emil Dotchevski
-
Oliver Kowalke
-
Tamas.Ruszkai@leica-geosystems.com