Improve the conditional usage of try catch

This commit is contained in:
Denis Blank 2018-02-06 00:54:11 +01:00
parent 752bee6ea4
commit c8b4e1ddcd
2 changed files with 4 additions and 5 deletions

View File

@ -36,6 +36,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <continuable/detail/features.hpp>
#include <continuable/detail/traits.hpp> #include <continuable/detail/traits.hpp>
#include <continuable/detail/types.hpp> #include <continuable/detail/types.hpp>
#include <continuable/detail/util.hpp> #include <continuable/detail/util.hpp>
@ -148,8 +149,7 @@ void assert_async_binary_exception_validation(V&& validator, C&& continuable,
ASSERT_FALSE(*called); ASSERT_FALSE(*called);
*called = true; *called = true;
#if !defined(CONTINUABLE_WITH_CUSTOM_ERROR_TYPE) && \ #if defined(CONTINUABLE_WITH_EXCEPTIONS)
!defined(CONTINUABLE_WITH_NO_EXCEPTIONS)
try { try {
std::rethrow_exception(error); std::rethrow_exception(error);
} catch (std::decay_t<decltype(expected)>& exception) { } catch (std::decay_t<decltype(expected)>& exception) {

View File

@ -96,8 +96,7 @@ public:
/// Resolves the promise through the exception /// Resolves the promise through the exception
void operator()(types::dispatch_error_tag, types::error_type error) { void operator()(types::dispatch_error_tag, types::error_type error) {
#if !defined(CONTINUABLE_WITH_CUSTOM_ERROR_TYPE) && \ #if defined(CONTINUABLE_WITH_EXCEPTIONS)
!defined(CONTINUABLE_WITH_NO_EXCEPTIONS)
promise_.set_exception(error); promise_.set_exception(error);
#else #else
(void)error; (void)error;
@ -106,7 +105,7 @@ public:
// to a std::promise. Handle the error first in order // to a std::promise. Handle the error first in order
// to prevent this trap! // to prevent this trap!
util::trap(); util::trap();
#endif #endif // CONTINUABLE_WITH_EXCEPTIONS
} }
/// Returns the future from the promise /// Returns the future from the promise