Add error handling to AsyncTaskThread::execAsync

This commit is contained in:
sfc-gh-tclinkenbeard 2020-10-20 13:45:37 -07:00
parent e9de39f525
commit 0879e529d2
1 changed files with 6 additions and 3 deletions

View File

@ -82,9 +82,12 @@ public:
}
Promise<decltype(func())> promise;
addTask([&promise, &func, priority] {
auto funcResult = func();
onMainThreadVoid([&promise, &funcResult] { promise.send(funcResult); }, nullptr,
priority); // TODO: Add error handling
try {
auto funcResult = func();
onMainThreadVoid([&promise, &funcResult] { promise.send(funcResult); }, nullptr, priority);
} catch (Error& e) {
onMainThreadVoid([&promise, &e] { promise.sendError(e); }, nullptr, priority);
}
});
return promise.getFuture();
}