From 45f374c80b3b8b3931ad37c1be7a1c6cf6970aaf Mon Sep 17 00:00:00 2001 From: super1207 <1875159423@qq.com> Date: Tue, 1 Feb 2022 22:59:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E5=BC=82=E5=B8=B8=E6=8D=95?= =?UTF-8?q?=E8=8E=B7=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MiraiCQ/MiraiCQ/tool/ThreadTool.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/MiraiCQ/MiraiCQ/tool/ThreadTool.cpp b/src/MiraiCQ/MiraiCQ/tool/ThreadTool.cpp index 65a53ee..103d53e 100644 --- a/src/MiraiCQ/MiraiCQ/tool/ThreadTool.cpp +++ b/src/MiraiCQ/MiraiCQ/tool/ThreadTool.cpp @@ -104,7 +104,14 @@ void ThreadTool::add_new_thread() } } /* 执行任务 */ - task(); + try { + task(); + } + catch (const std::exception& e) { + MiraiLog::get_instance()->add_fatal_log("ThreadTool", std::string("在ThreadTool中发生未知错误:") + e.what()); + exit(-1); + } + } --cur_thread_nums; }).detach();