diff --git a/include/continuable/detail/core/base.hpp b/include/continuable/detail/core/base.hpp index 8822f7c..83a1750 100644 --- a/include/continuable/detail/core/base.hpp +++ b/include/continuable/detail/core/base.hpp @@ -165,8 +165,18 @@ constexpr auto invoke_callback(T&& callable, Args&&... args) { /// Invokes the given callable object with the given arguments while /// marking the operation as non exceptional. template -constexpr auto invoke_no_except(T&& callable, Args&&... args) noexcept { - return std::forward(callable)(std::forward(args)...); +constexpr void invoke_no_except(T&& callable, Args&&... args) noexcept { + std::forward(callable)(std::forward(args)...); +} + +template +void invoke_void_no_except(traits::identity, + T&& /*callable*/) noexcept { + // Don't invoke the next failure handler when being in an exception handler +} +template +void invoke_void_no_except(traits::identity, T&& callable) noexcept { + std::forward(callable)(); } template @@ -224,7 +234,8 @@ inline auto invoker_of(traits::identity) { CONTINUABLE_BLOCK_TRY_BEGIN invoke_callback(std::forward(callback), std::forward(args)...); - invoke_no_except( + invoke_void_no_except( + traits::identity...>{}, std::forward(next_callback)); CONTINUABLE_BLOCK_TRY_END }, @@ -296,8 +307,8 @@ auto invoker_of(traits::identity>) { exception_arg_t{}, std::move(result).get_exception()); } - // Otherwise the result is empty and we are cancelling our - // asynchronous chain. + // Otherwise the result is empty and we are cancelling our + // asynchronous chain. CONTINUABLE_BLOCK_TRY_END }, traits::identity{}); @@ -338,37 +349,6 @@ constexpr auto invoker_of(traits::identity>) { return make_invoker(sequenced_unpack_invoker(), traits::identity{}); } -inline auto exception_invoker_of(traits::identity) noexcept { - return [](auto&& callback, auto&& next_callback, auto&&... args) { - CONTINUABLE_BLOCK_TRY_BEGIN - invoke_callback(std::forward(callback), - std::forward(args)...); - - // The legacy behaviour is not to proceed the chain - // on the first invoked failure handler - (void)next_callback; - CONTINUABLE_BLOCK_TRY_END - }; -} - -inline auto exception_invoker_of(traits::identity id) noexcept { - return invoker_of(id); -} -inline auto -exception_invoker_of(traits::identity id) noexcept { - return invoker_of(id); -} -template -auto exception_invoker_of(traits::identity> id) noexcept { - return invoker_of(id); -} - -template -auto exception_invoker_of( - traits::identity> id) { - return invoker_of(id); -} - #undef CONTINUABLE_BLOCK_TRY_BEGIN #undef CONTINUABLE_BLOCK_TRY_END } // namespace decoration @@ -475,7 +455,7 @@ struct error_handler_base { std::move(static_cast(this)->callback_), exception_arg_t{}, std::move(exception)))>{}; - auto invoker = decoration::exception_invoker_of(result); + auto invoker = decoration::invoker_of(result); // Invoke the error handler on_executor(std::move(static_cast(this)->executor_),