From 2c7001fbd59d8ee3aa6706404d1ff4ecd25e97d5 Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Tue, 10 Sep 2024 01:10:50 +0800 Subject: [PATCH] chore: catch synclaunch exception --- src/ll/api/coro/CoroTask.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ll/api/coro/CoroTask.h b/src/ll/api/coro/CoroTask.h index 53ecbedee5..dbc8c9ff82 100644 --- a/src/ll/api/coro/CoroTask.h +++ b/src/ll/api/coro/CoroTask.h @@ -86,14 +86,18 @@ class CoroTask { }(std::move(*this), std::forward(callback)); } - ExpectedT syncLaunch(Executor const& executor) { - std::binary_semaphore cond{0}; - ExpectedT value; - launch(executor, [&](ExpectedT&& result) { - value = std::move(result); - cond.release(); - }); - cond.acquire(); + ExpectedT syncLaunch(Executor const& executor) noexcept { + ExpectedT value; + try { + std::binary_semaphore cond{0}; + launch(executor, [&](ExpectedT&& result) { + value = std::move(result); + cond.release(); + }); + cond.acquire(); + } catch (...) { + value = makeExceptionError(); + } return value; } };