diff --git a/include/continuable/detail/base.hpp b/include/continuable/detail/base.hpp index 4c1c4e4..3e42275 100644 --- a/include/continuable/detail/base.hpp +++ b/include/continuable/detail/base.hpp @@ -333,16 +333,18 @@ struct error_callback, Callback, Executor, } /// The operator which is called when an error occurred - void operator()(types::dispatch_error_tag /*tag*/, - types::error_type /*error*/) { - /* - *TODO - *auto invoker = [] {}; + void operator()(types::dispatch_error_tag /*tag*/, types::error_type error) { - // Forward the error to the error handler + // Just invoke the error handler, cancel the calling hierarchy then + auto invoker = [](Callback&& callback, NextCallback&&, + types::error_type&& error) { + callback(std::move(error)); + }; + + // Invoke the error handler packed_dispatch(std::move(executor_), std::move(invoker), std::move(callback_), std::move(next_callback_), - std::move(error));*/ + std::move(error)); } /// Resolves the continuation with the given values diff --git a/include/continuable/detail/features.hpp b/include/continuable/detail/features.hpp index f007053..29b2acd 100644 --- a/include/continuable/detail/features.hpp +++ b/include/continuable/detail/features.hpp @@ -31,6 +31,7 @@ #define CONTINUABLE_DETAIL_FEATURES_HPP_INCLUDED__ // Defines CONTINUABLE_WITH_NO_EXCEPTIONS when exception support is disabled +#ifndef CONTINUABLE_WITH_NO_EXCEPTIONS #if defined(_MSC_VER) #if !defined(_HAS_EXCEPTIONS) || (_HAS_EXCEPTIONS == 0) #define CONTINUABLE_WITH_NO_EXCEPTIONS @@ -44,6 +45,7 @@ #define CONTINUABLE_WITH_NO_EXCEPTIONS #endif #endif +#endif // CONTINUABLE_WITH_NO_EXCEPTIONS #undef CONTINUABLE_HAS_CXX17_CONSTEXPR_IF #undef CONTINUABLE_HAS_CXX17_FOLD_EXPRESSION diff --git a/include/continuable/detail/types.hpp b/include/continuable/detail/types.hpp index 23faf57..f3be119 100644 --- a/include/continuable/detail/types.hpp +++ b/include/continuable/detail/types.hpp @@ -34,7 +34,7 @@ #ifndef CONTINUABLE_WITH_NO_EXCEPTIONS #include #else // CONTINUABLE_WITH_NO_EXCEPTIONS -#include +#include #endif // CONTINUABLE_WITH_NO_EXCEPTIONS #include diff --git a/test/playground/CMakeLists.txt b/test/playground/CMakeLists.txt index 3e060de..842cd9e 100644 --- a/test/playground/CMakeLists.txt +++ b/test/playground/CMakeLists.txt @@ -30,5 +30,9 @@ target_link_libraries(test-playground PRIVATE continuable) +target_compile_definitions(test-playground + PUBLIC + -DCONTINUABLE_WITH_NO_EXCEPTIONS) + add_test(NAME continuable-playground-tests COMMAND test-playground) diff --git a/test/playground/test-playground.cpp b/test/playground/test-playground.cpp index 2048fda..badf33e 100644 --- a/test/playground/test-playground.cpp +++ b/test/playground/test-playground.cpp @@ -20,8 +20,10 @@ SOFTWARE. **/ -#include #include +#include + +#include static cti::continuable http_request(std::string url) { return [url = std::move(url)](cti::promise promise) { @@ -29,7 +31,7 @@ static cti::continuable http_request(std::string url) { promise.set_value(""); promise(""); } - promise.set_exception(nullptr); + promise.set_exception(std::error_condition{}); }; } @@ -37,9 +39,11 @@ static cti::continuable http_request(std::string url) { // TODO Fix this static cti::continuable http_request(std::string url) { return [url = std::move(url)](auto promise) { - promise.set_exception(nullptr); - promise.set_value(""); - promise(""); + if (false) { + promise.set_value(""); + promise(""); + } + promise.set_exception(std::error_condition{}); }; } */ @@ -52,7 +56,7 @@ static auto http_request2(std::string url) { promise.set_value(""); promise(""); } - promise.set_exception(nullptr); + promise.set_exception(std::error_condition{}); }); } @@ -61,7 +65,7 @@ int main(int, char**) { .then([](std::string) { // ... }) - .catching([](std::exception_ptr) { + .catching([](std::error_condition) { // ... }); @@ -69,7 +73,7 @@ int main(int, char**) { .then([](std::string) { // ... }) - .catching([](std::exception_ptr) { + .catching([](std::error_condition) { // ... });