Commit 90052551 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

co_await co_throw => co_yield co_error

Reviewed By: yfeldblum, lewissbaker

Differential Revision: D19156701

fbshipit-source-id: 80bd8b7fc6dfde71756411342e5f4eb912150f06
parent c4a9979c
......@@ -21,9 +21,9 @@
namespace folly {
namespace coro {
class co_throw {
class co_error {
public:
explicit co_throw(exception_wrapper ex) : ex_(std::move(ex)) {}
explicit co_error(exception_wrapper ex) : ex_(std::move(ex)) {}
const exception_wrapper& exception() const {
return ex_;
......
......@@ -28,8 +28,8 @@
#include <folly/Traits.h>
#include <folly/Try.h>
#include <folly/experimental/coro/CurrentExecutor.h>
#include <folly/experimental/coro/Error.h>
#include <folly/experimental/coro/Invoke.h>
#include <folly/experimental/coro/Throw.h>
#include <folly/experimental/coro/Traits.h>
#include <folly/experimental/coro/Utils.h>
#include <folly/experimental/coro/ViaIfAsync.h>
......@@ -157,9 +157,7 @@ class TaskPromise : public TaskPromiseBase {
return result_;
}
using TaskPromiseBase::await_transform;
auto await_transform(co_throw ex) {
auto yield_value(co_error ex) {
result_.emplaceException(std::move(ex.exception()));
return final_suspend();
}
......@@ -190,9 +188,7 @@ class TaskPromise<void> : public TaskPromiseBase {
return result_;
}
using TaskPromiseBase::await_transform;
auto await_transform(co_throw ex) {
auto yield_value(co_error ex) {
result_.emplaceException(std::move(ex.exception()));
return final_suspend();
}
......
......@@ -606,7 +606,7 @@ TEST(Coro, CoThrow) {
};
EXPECT_THROW(
folly::coro::blockingWait([]() -> folly::coro::Task<int> {
co_await folly::coro::co_throw(ExpectedException());
co_yield folly::coro::co_error(ExpectedException());
EXPECT_TRUE(false) << "unreachable";
co_return 42;
}()),
......@@ -614,7 +614,7 @@ TEST(Coro, CoThrow) {
EXPECT_THROW(
folly::coro::blockingWait([]() -> folly::coro::Task<void> {
co_await folly::coro::co_throw(ExpectedException());
co_yield folly::coro::co_error(ExpectedException());
EXPECT_TRUE(false) << "unreachable";
}()),
ExpectedException);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment