mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 08:46:44 +08:00
More implementation work on error handling
This commit is contained in:
parent
8856f85388
commit
e594989af2
@ -333,16 +333,18 @@ struct error_callback<hints::signature_hint_tag<Args...>, 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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
#ifndef CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
#include <exception>
|
||||
#else // CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
#include <error>
|
||||
#include <system_error>
|
||||
#endif // CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
|
||||
#include <continuable/detail/api.hpp>
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -20,8 +20,10 @@
|
||||
SOFTWARE.
|
||||
**/
|
||||
|
||||
#include <continuable/continuable.hpp>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
#include <continuable/continuable.hpp>
|
||||
|
||||
static cti::continuable<std::string> http_request(std::string url) {
|
||||
return [url = std::move(url)](cti::promise<std::string> promise) {
|
||||
@ -29,7 +31,7 @@ static cti::continuable<std::string> 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<std::string> http_request(std::string url) {
|
||||
// TODO Fix this
|
||||
static cti::continuable<std::string> 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) {
|
||||
// ...
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user