mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-29 22:55:52 +08:00
新增hook回调抛异常处理逻辑
This commit is contained in:
parent
e4cdc5f213
commit
290b3f37a5
@ -83,18 +83,25 @@ static void parse_http_response(const SockException &ex,
|
|||||||
fun(Json::nullValue, errStr);
|
fun(Json::nullValue, errStr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Value result;
|
||||||
try {
|
try {
|
||||||
stringstream ss(res.Content());
|
stringstream ss(res.Content());
|
||||||
Value result;
|
|
||||||
ss >> result;
|
ss >> result;
|
||||||
|
} catch (std::exception &ex) {
|
||||||
|
auto errStr = StrPrinter << "[parse json failed]:" << ex.what() << endl;
|
||||||
|
fun(Json::nullValue, errStr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (result["code"].asInt() != 0) {
|
if (result["code"].asInt() != 0) {
|
||||||
auto errStr = StrPrinter << "[json code]:" << "code=" << result["code"] << ",msg=" << result["msg"] << endl;
|
auto errStr = StrPrinter << "[json code]:" << "code=" << result["code"] << ",msg=" << result["msg"] << endl;
|
||||||
fun(Json::nullValue, errStr);
|
fun(Json::nullValue, errStr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
fun(result, "");
|
fun(result, "");
|
||||||
} catch (std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
auto errStr = StrPrinter << "[parse json failed]:" << ex.what() << endl;
|
auto errStr = StrPrinter << "[do hook invoker failed]:" << ex.what() << endl;
|
||||||
|
//如果还是抛异常,那么再上抛异常
|
||||||
fun(Json::nullValue, errStr);
|
fun(Json::nullValue, errStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user