From 3cec02b81923c5ee1d2a33415145de8ba58032ee Mon Sep 17 00:00:00 2001 From: xx Date: Fri, 7 Jun 2024 19:45:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/util/localstorage.h | 2 +- src/net/http_router.cpp | 10 +++++++++- src/util/localstorage.cpp | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/util/localstorage.h b/include/util/localstorage.h index 4770411..f7b34fe 100644 --- a/include/util/localstorage.h +++ b/include/util/localstorage.h @@ -64,7 +64,7 @@ namespace ylib /// [测试] 生成GUID /// /// - std::string test_make_guid(); + //std::string test_make_guid(); private: // 目录 std::string m_dirpath; diff --git a/src/net/http_router.cpp b/src/net/http_router.cpp index 78937e1..84d00d3 100644 --- a/src/net/http_router.cpp +++ b/src/net/http_router.cpp @@ -220,7 +220,15 @@ void ylib::network::http::router::__thread_callback(reqpack* rp) if(execed == false){ //其它回调 if (m_callback_other != nullptr) { - m_callback_other(rp->request(), rp->response()); + try + { + m_callback_other(rp->request(), rp->response()); + } + catch (const std::exception& e) + { + rp->response()->send((std::string)e.what(), 500, "Internal Server Error"); + } + }else{ rp->response()->send((std::string)"Services that have not been processed",500,"Service Unavailable"); } diff --git a/src/util/localstorage.cpp b/src/util/localstorage.cpp index ffbfc7a..ccd4d97 100644 --- a/src/util/localstorage.cpp +++ b/src/util/localstorage.cpp @@ -65,7 +65,7 @@ bool ylib::local_storage::exist(const std::string& name) return false; } -std::string ylib::local_storage::test_make_guid() -{ - return codec::md5(std::to_string(time::now_msec()) + std::to_string(m_guid_counter.make())); -} +//std::string ylib::local_storage::test_make_guid() +//{ +// return codec::md5(std::to_string(time::now_msec()) + std::to_string(m_guid_counter.make())); +//}