From 290b3f37a51c0d5941682cd34c1c498c13d3e424 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Thu, 14 Oct 2021 16:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Ehook=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E6=8A=9B=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebHook.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 29bc6a9b..3e84e5bf 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -83,19 +83,26 @@ static void parse_http_response(const SockException &ex, fun(Json::nullValue, errStr); return; } + Value result; try { stringstream ss(res.Content()); - Value result; ss >> result; - if (result["code"].asInt() != 0) { - auto errStr = StrPrinter << "[json code]:" << "code=" << result["code"] << ",msg=" << result["msg"] << endl; - fun(Json::nullValue, errStr); - return; - } - fun(result, ""); } catch (std::exception &ex) { auto errStr = StrPrinter << "[parse json failed]:" << ex.what() << endl; fun(Json::nullValue, errStr); + return; + } + if (result["code"].asInt() != 0) { + auto errStr = StrPrinter << "[json code]:" << "code=" << result["code"] << ",msg=" << result["msg"] << endl; + fun(Json::nullValue, errStr); + return; + } + try { + fun(result, ""); + } catch (std::exception &ex) { + auto errStr = StrPrinter << "[do hook invoker failed]:" << ex.what() << endl; + //如果还是抛异常,那么再上抛异常 + fun(Json::nullValue, errStr); } }