From ddd5b0a0a62047bf141c07fafc0f8d201a827c02 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Wed, 4 Oct 2017 02:23:55 +0200 Subject: [PATCH] more --- include/continuable/detail/base.hpp | 15 +++++++++++++++ include/continuable/detail/transforms.hpp | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/continuable/detail/base.hpp b/include/continuable/detail/base.hpp index 530d853..0842b1e 100644 --- a/include/continuable/detail/base.hpp +++ b/include/continuable/detail/base.hpp @@ -35,6 +35,11 @@ #include #include +#if !defined(CONTINUABLE_WITH_CUSTOM_ERROR_TYPE) && \ + !defined(CONTINUABLE_WITH_NO_EXCEPTIONS) +#include +#endif + #include #include #include @@ -235,8 +240,18 @@ template void packed_dispatch(types::this_thread_executor_tag, Invoker&& invoker, Args&&... args) { + !defined(CONTINUABLE_WITH_NO_EXCEPTIONS) + // Make it possible to throw exceptions from continuations chained + // through `then` or `flow`. + try { + std::forward(invoker)(std::forward(args)...); + } catch (...) { + std::current_exception(); + } +#else // Invoke the callback with the decorated invoker immediately std::forward(invoker)(std::forward(args)...); +#endif } /// Invoke the callback through the given executor diff --git a/include/continuable/detail/transforms.hpp b/include/continuable/detail/transforms.hpp index c775b83..7a9007a 100644 --- a/include/continuable/detail/transforms.hpp +++ b/include/continuable/detail/transforms.hpp @@ -128,7 +128,7 @@ auto as_future(continuable_base&& continuable) { auto future = callback.get_future(); // Dispatch the continuation with the promise resolving callback - std::move(continuable).then(std::move(callback)).done(); + std::move(continuable).flow(std::move(callback)).done(); return future; }