From c8b4e1ddcd3a3e4074e41443b691bf16f3d3fd58 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Tue, 6 Feb 2018 00:54:11 +0100 Subject: [PATCH] Improve the conditional usage of try catch --- include/continuable/detail/testing.hpp | 4 ++-- include/continuable/detail/transforms.hpp | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/continuable/detail/testing.hpp b/include/continuable/detail/testing.hpp index 1f30fe9..77ca189 100644 --- a/include/continuable/detail/testing.hpp +++ b/include/continuable/detail/testing.hpp @@ -36,6 +36,7 @@ #include +#include #include #include #include @@ -148,8 +149,7 @@ void assert_async_binary_exception_validation(V&& validator, C&& continuable, ASSERT_FALSE(*called); *called = true; -#if !defined(CONTINUABLE_WITH_CUSTOM_ERROR_TYPE) && \ - !defined(CONTINUABLE_WITH_NO_EXCEPTIONS) +#if defined(CONTINUABLE_WITH_EXCEPTIONS) try { std::rethrow_exception(error); } catch (std::decay_t& exception) { diff --git a/include/continuable/detail/transforms.hpp b/include/continuable/detail/transforms.hpp index b4b6892..c0d9e78 100644 --- a/include/continuable/detail/transforms.hpp +++ b/include/continuable/detail/transforms.hpp @@ -96,8 +96,7 @@ public: /// Resolves the promise through the exception void operator()(types::dispatch_error_tag, types::error_type error) { -#if !defined(CONTINUABLE_WITH_CUSTOM_ERROR_TYPE) && \ - !defined(CONTINUABLE_WITH_NO_EXCEPTIONS) +#if defined(CONTINUABLE_WITH_EXCEPTIONS) promise_.set_exception(error); #else (void)error; @@ -106,7 +105,7 @@ public: // to a std::promise. Handle the error first in order // to prevent this trap! util::trap(); -#endif +#endif // CONTINUABLE_WITH_EXCEPTIONS } /// Returns the future from the promise