add exception handle.

This commit is contained in:
amass 2024-05-05 22:00:15 +08:00
parent db1e7d5cfb
commit 3fa2c054e2

View File

@ -7,6 +7,7 @@
#include "ServiceManager.h"
#include "SystemUsage.h"
#include "WeChatContext/CorporationContext.h"
#include <boost/stacktrace.hpp>
Application::Application(const std::string &path)
: ApplicationSettings(path), m_router{std::make_shared<boost::urls::router<RequestHandler>>()} {
@ -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() {