Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task exceptions are not forwarded to caller #14

Closed
fmoessbauer opened this issue Jun 22, 2021 · 2 comments
Closed

Task exceptions are not forwarded to caller #14

fmoessbauer opened this issue Jun 22, 2021 · 2 comments

Comments

@fmoessbauer
Copy link

In case an exception is thrown inside a task, this exception leads to the direct termination of the application.
To fix that, the scheduler has to catch the exception in the sub-task and set the exception-context of the promise object itself.
For details, see cppreference: https://en.cppreference.com/w/cpp/thread/promise/set_exception

Example:

auto fut = pool.submit([](){throw std::runtime_error("error");});
try {
  fut.get();
} catch(std::runtime_error & e){
  std::cout << "catched error" << std::endl;
}

This application terminates with:

terminate called after throwing an instance of 'std::runtime_error'
@bshoshany
Copy link
Owner

Thanks for the suggestion! I will fix this in the next release.

@bshoshany
Copy link
Owner

Update: This has now been fixed in v1.8!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants