mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
Rename catching -> fail
This commit is contained in:
parent
52fb13387d
commit
bc431b4013
@ -227,16 +227,18 @@ public:
|
||||
}
|
||||
|
||||
/// Main method of the continuable_base to catch exceptions and error codes
|
||||
/// in case the asynchronous control flow failed and was resolved
|
||||
/// through an error code or exception.
|
||||
///
|
||||
/// \param callback The callback which is used to process the current
|
||||
/// asynchronous error result on arrival.
|
||||
/// In case the continuable_base is using exceptions, the usage is as
|
||||
/// shown below:
|
||||
/// In case the continuable_base is using exceptions,
|
||||
/// the usage is as shown below:
|
||||
///
|
||||
/// ```cpp
|
||||
/// http_request("github.com")
|
||||
/// .then([](std::string github) { })
|
||||
/// .catching([](std::exception_ptr ptr) {
|
||||
/// .fail([](std::exception_ptr ptr) {
|
||||
/// // Handle the error here
|
||||
/// try {
|
||||
/// std::rethrow_exception(ptr);
|
||||
@ -250,7 +252,7 @@ public:
|
||||
/// ```cpp
|
||||
/// http_request("github.com")
|
||||
/// .then([](std::string github) { })
|
||||
/// .catching([](std::error_condition error) {
|
||||
/// .fail([](std::error_condition error) {
|
||||
/// error.message(); // Handle the error here
|
||||
/// });
|
||||
/// ```
|
||||
@ -264,7 +266,7 @@ public:
|
||||
///
|
||||
/// \since version 2.0.0
|
||||
template <typename T, typename E = detail::types::this_thread_executor_tag>
|
||||
auto catching(T&& callback,
|
||||
auto fail(T&& callback,
|
||||
E&& executor = detail::types::this_thread_executor_tag{}) && {
|
||||
return detail::base::chain_error_handler(std::move(*this).materialize(),
|
||||
std::forward<T>(callback),
|
||||
|
||||
@ -67,7 +67,6 @@ using continuable = typename detail::trait_of<
|
||||
/// function2 backend for the continuable type erasure.
|
||||
///
|
||||
/// Usable like: `callback<int, float>`
|
||||
// TODO Decide whether promises are copyable
|
||||
// template <typename... Args>
|
||||
// using promise = typename detail::trait_of<
|
||||
// Args...
|
||||
|
||||
@ -64,18 +64,26 @@ int main(int, char**) {
|
||||
http_request("github.com")
|
||||
.then([](std::string) {
|
||||
// ...
|
||||
return 0;
|
||||
})
|
||||
.catching([](std::error_condition) {
|
||||
.fail([](std::error_condition) {
|
||||
// ...
|
||||
})
|
||||
.then([](int) {
|
||||
// ...
|
||||
});
|
||||
|
||||
/*http_request2("github.com")
|
||||
http_request2("github.com")
|
||||
.then([](std::string) {
|
||||
// ...
|
||||
return 0;
|
||||
})
|
||||
.catching([](std::error_condition) {
|
||||
.fail([](std::error_condition) {
|
||||
// ...
|
||||
});*/
|
||||
})
|
||||
.then([](int) {
|
||||
// ...
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user