Avoid task execution to crash thread pool

PiperOrigin-RevId: 517980691
This commit is contained in:
Guogang Li
2023-03-20 08:53:03 -07:00
committed by Copybara-Service
parent 12156937ee
commit 465a82dc1e
@@ -16,7 +16,6 @@
#include <windows.h>
#include <exception>
#include <queue>
#include <utility>
@@ -24,7 +23,6 @@
#include "absl/synchronization/mutex.h"
#include "internal/platform/logging.h"
#include "internal/platform/runnable.h"
#include "winrt/base.h"
namespace nearby {
namespace windows {
@@ -159,16 +157,7 @@ void ThreadPool::RunNextTask() {
return;
}
try {
task();
} catch (std::exception exception) {
NEARBY_LOGS(ERROR) << __func__ << ": Exception: " << exception.what();
} catch (const winrt::hresult_error& error) {
NEARBY_LOGS(ERROR) << __func__ << ": WinRT exception: " << error.code()
<< ": " << winrt::to_string(error.message());
} catch (...) {
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exeption.";
}
task();
}
} // namespace windows