diff --git a/fdbclient/AsyncTaskThread.h b/fdbclient/AsyncTaskThread.h index b55ff3d02b..c1c5d1be3e 100644 --- a/fdbclient/AsyncTaskThread.h +++ b/fdbclient/AsyncTaskThread.h @@ -82,9 +82,12 @@ public: } Promise 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(); }