mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
Improve the conditional usage of try catch
This commit is contained in:
parent
752bee6ea4
commit
c8b4e1ddcd
@ -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) {
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user