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 <continuable/detail/features.hpp>
#include <continuable/detail/traits.hpp>
#include <continuable/detail/types.hpp>
#include <continuable/detail/util.hpp>
@ -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<decltype(expected)>& exception) {

View File

@ -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