mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 01:06: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
|
/// 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
|
/// \param callback The callback which is used to process the current
|
||||||
/// asynchronous error result on arrival.
|
/// asynchronous error result on arrival.
|
||||||
/// In case the continuable_base is using exceptions, the usage is as
|
/// In case the continuable_base is using exceptions,
|
||||||
/// shown below:
|
/// the usage is as shown below:
|
||||||
///
|
///
|
||||||
/// ```cpp
|
/// ```cpp
|
||||||
/// http_request("github.com")
|
/// http_request("github.com")
|
||||||
/// .then([](std::string github) { })
|
/// .then([](std::string github) { })
|
||||||
/// .catching([](std::exception_ptr ptr) {
|
/// .fail([](std::exception_ptr ptr) {
|
||||||
/// // Handle the error here
|
/// // Handle the error here
|
||||||
/// try {
|
/// try {
|
||||||
/// std::rethrow_exception(ptr);
|
/// std::rethrow_exception(ptr);
|
||||||
@ -250,7 +252,7 @@ public:
|
|||||||
/// ```cpp
|
/// ```cpp
|
||||||
/// http_request("github.com")
|
/// http_request("github.com")
|
||||||
/// .then([](std::string github) { })
|
/// .then([](std::string github) { })
|
||||||
/// .catching([](std::error_condition error) {
|
/// .fail([](std::error_condition error) {
|
||||||
/// error.message(); // Handle the error here
|
/// error.message(); // Handle the error here
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
@ -264,7 +266,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// \since version 2.0.0
|
/// \since version 2.0.0
|
||||||
template <typename T, typename E = detail::types::this_thread_executor_tag>
|
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{}) && {
|
E&& executor = detail::types::this_thread_executor_tag{}) && {
|
||||||
return detail::base::chain_error_handler(std::move(*this).materialize(),
|
return detail::base::chain_error_handler(std::move(*this).materialize(),
|
||||||
std::forward<T>(callback),
|
std::forward<T>(callback),
|
||||||
|
|||||||
@ -67,7 +67,6 @@ using continuable = typename detail::trait_of<
|
|||||||
/// function2 backend for the continuable type erasure.
|
/// function2 backend for the continuable type erasure.
|
||||||
///
|
///
|
||||||
/// Usable like: `callback<int, float>`
|
/// Usable like: `callback<int, float>`
|
||||||
// TODO Decide whether promises are copyable
|
|
||||||
// template <typename... Args>
|
// template <typename... Args>
|
||||||
// using promise = typename detail::trait_of<
|
// using promise = typename detail::trait_of<
|
||||||
// Args...
|
// Args...
|
||||||
|
|||||||
@ -64,18 +64,26 @@ int main(int, char**) {
|
|||||||
http_request("github.com")
|
http_request("github.com")
|
||||||
.then([](std::string) {
|
.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) {
|
.then([](std::string) {
|
||||||
// ...
|
// ...
|
||||||
|
return 0;
|
||||||
})
|
})
|
||||||
.catching([](std::error_condition) {
|
.fail([](std::error_condition) {
|
||||||
// ...
|
// ...
|
||||||
});*/
|
})
|
||||||
|
.then([](int) {
|
||||||
|
// ...
|
||||||
|
});
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user