Fix more build failures regarding error handling

This commit is contained in:
Denis Blank 2017-10-01 01:26:49 +02:00
parent 5d11d44a44
commit 8856f85388
4 changed files with 27 additions and 11 deletions

View File

@ -53,6 +53,7 @@ template <template <typename...> class CallbackWrapper,
template <typename...> class ContinuationWrapper, typename... Args>
struct continuable_trait {
/// The callback type which is passed to continuations
// TODO This should be void(promise<...>) I think
using callback =
CallbackWrapper<void(Args...), void(detail::types::dispatch_error_tag,
detail::types::error_type)>;

View File

@ -305,12 +305,12 @@ struct result_callback<hints::signature_hint_tag<Args...>, Callback, Executor,
/// Resolves the continuation with the given values
void set_value(Args... args) {
std::move(next_callback_)(std::move(args)...);
(*this)(std::move(args)...);
}
/// Resolves the continuation with the given error variable.
void set_exception(types::error_type error) {
std::move(next_callback_)(types::dispatch_error_tag{}, std::move(error));
(*this)(types::dispatch_error_tag{}, std::move(error));
}
};
@ -346,13 +346,13 @@ struct error_callback<hints::signature_hint_tag<Args...>, Callback, Executor,
}
/// Resolves the continuation with the given values
void set_value(Args... /*args*/) {
// std::move(next_callback_)(std::move(args)...);
void set_value(Args... args) {
(*this)(std::move(args)...);
}
/// Resolves the continuation with the given error variable.
void set_exception(types::error_type /*error*/) {
// std::move(next_callback_)(types::dispatch_error_tag{}, std::move(error));
void set_exception(types::error_type error) {
(*this)(types::dispatch_error_tag{}, std::move(error));
}
};

View File

@ -135,7 +135,7 @@ public:
/// Creates a submitter which submits it's result into the tuple
template <std::size_t From, std::size_t To>
auto create_callback(traits::size_constant<From> from,
traits::size_constant<To> to) {
traits::size_constant<To> /*to*/) {
return [ me = this->shared_from_this(), from ](auto&&... args) {
static_assert(sizeof...(args) == (To - From),

View File

@ -25,25 +25,40 @@
static cti::continuable<std::string> http_request(std::string url) {
return [url = std::move(url)](cti::promise<std::string> promise) {
if (false) {
promise.set_value("");
promise("");
}
promise.set_exception(nullptr);
};
}
/*
// 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("");
};
}
*/
static auto http_request2(std::string url) {
return cti::make_continuable<std::string>(
// ...
[url = std::move(url)](auto&& promise) {
if (false) {
promise.set_value("");
promise("");
}
promise.set_exception(nullptr);
promise.set_value("");
promise("");
});
}
int main(int, char**) {
http_request("github.com")
.then([](std::string /*response*/) {
.then([](std::string) {
// ...
})
.catching([](std::exception_ptr) {
@ -51,7 +66,7 @@ int main(int, char**) {
});
http_request2("github.com")
.then([](std::string /*response*/) {
.then([](std::string) {
// ...
})
.catching([](std::exception_ptr) {