Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 009c6b6

Browse files
committed
修复GetXMessageFromId未检测返回代码的问题;
1 parent ab6c1c8 commit 009c6b6

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/mirai_bot.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,14 @@ namespace Cyan
529529
json reJson;
530530
reJson = reJson.parse(res.Content);
531531
if (!reJson.is_object()) throw runtime_error("解析返回 JSON 时出错");
532-
result.Set(reJson["data"]);
532+
int code = reJson["code"].get<int>();
533+
if (code == 0)
534+
result.Set(reJson["data"]);
535+
else
536+
{
537+
string msg = reJson["msg"].get<string>();
538+
throw runtime_error(msg);
539+
}
533540
return result;
534541
}
535542
else
@@ -556,7 +563,14 @@ namespace Cyan
556563
json reJson;
557564
reJson = reJson.parse(res.Content);
558565
if (!reJson.is_object()) throw runtime_error("解析返回 JSON 时出错");
559-
result.Set(reJson["data"]);
566+
int code = reJson["code"].get<int>();
567+
if (code == 0)
568+
result.Set(reJson["data"]);
569+
else
570+
{
571+
string msg = reJson["msg"].get<string>();
572+
throw runtime_error(msg);
573+
}
560574
return result;
561575
}
562576
else

0 commit comments

Comments
 (0)