add exception handle.
This commit is contained in:
parent
db1e7d5cfb
commit
3fa2c054e2
@ -7,6 +7,7 @@
|
|||||||
#include "ServiceManager.h"
|
#include "ServiceManager.h"
|
||||||
#include "SystemUsage.h"
|
#include "SystemUsage.h"
|
||||||
#include "WeChatContext/CorporationContext.h"
|
#include "WeChatContext/CorporationContext.h"
|
||||||
|
#include <boost/stacktrace.hpp>
|
||||||
|
|
||||||
Application::Application(const std::string &path)
|
Application::Application(const std::string &path)
|
||||||
: ApplicationSettings(path), m_router{std::make_shared<boost::urls::router<RequestHandler>>()} {
|
: 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,
|
const Application::RequestHandler *Application::find(boost::urls::segments_encoded_view path,
|
||||||
boost::urls::matches_base &matches) const noexcept {
|
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() {
|
int Application::exec() {
|
||||||
|
Loading…
Reference in New Issue
Block a user