From 2a9ee59cc479eba28eb8eeabe28fbc81ad77b3fe Mon Sep 17 00:00:00 2001 From: Aleksandra Martyniuk Date: Thu, 17 Aug 2023 16:37:14 +0200 Subject: [PATCH] tasks: fail if a task was aborted run() method of task_manager::task::impl does not have to throw when a task is aborted with task manager api. Thus, a user will see that the task finished successfully which makes it inconsistent. Finish a task with a failure if it was aborted with task manager api. --- tasks/task_manager.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tasks/task_manager.cc b/tasks/task_manager.cc index 75a194887a..ea58e99544 100644 --- a/tasks/task_manager.cc +++ b/tasks/task_manager.cc @@ -124,7 +124,12 @@ void task_manager::task::impl::run_to_completion() { if (f.failed()) { finish_failed(f.get_exception()); } else { - finish(); + try { + _as.check(); + finish(); + } catch (...) { + finish_failed(std::current_exception()); + } } }); }