From 3fa2c054e2a4b11f0a190a5f5cdefea28e47675a Mon Sep 17 00:00:00 2001 From: amass <168062547@qq.com> Date: Sun, 5 May 2024 22:00:15 +0800 Subject: [PATCH] add exception handle. --- Server/Application.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Server/Application.cpp b/Server/Application.cpp index 22aacc1..d26a18f 100644 --- a/Server/Application.cpp +++ b/Server/Application.cpp @@ -7,6 +7,7 @@ #include "ServiceManager.h" #include "SystemUsage.h" #include "WeChatContext/CorporationContext.h" +#include Application::Application(const std::string &path) : ApplicationSettings(path), m_router{std::make_shared>()} { @@ -135,7 +136,14 @@ boost::asio::io_context &Application::ioContext() { const Application::RequestHandler *Application::find(boost::urls::segments_encoded_view path, boost::urls::matches_base &matches) const noexcept { - return m_router->find(path, matches); + const Application::RequestHandler *ret = nullptr; + try { + ret = m_router->find(path, matches); + } catch (const std::exception &e) { + boost::stacktrace::stacktrace trace = boost::stacktrace::stacktrace::from_current_exception(); + LOG(error) << e.what() << ", trace:\n" << trace; + } + return ret; } int Application::exec() {