fix(robot_agent): 用 boost::system::error_code 替代已移除的 json::error_code 别名
新版 Boost(1.85+)移除了 boost::json::error_code 废弃别名, 改用 boost::system::error_code 以兼容新旧版本。
This commit is contained in:
1 parent
67acae708c
commit
dbfb925f65
1 file changed
+4
-2
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <us/HttpClient.hpp>
|
#include <us/HttpClient.hpp>
|
||||||
|
|
||||||
|
#include <boost/system/error_code.hpp>
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -90,7 +92,7 @@ std::string run_chat_loop(const AgentConfig& cfg,
|
|||||||
if (code != 200)
|
if (code != 200)
|
||||||
throw std::runtime_error("HTTP " + std::to_string(code) + ": " + response_body);
|
throw std::runtime_error("HTTP " + std::to_string(code) + ": " + response_body);
|
||||||
|
|
||||||
json::error_code ec;
|
boost::system::error_code ec;
|
||||||
json::value resp = json::parse(response_body, ec);
|
json::value resp = json::parse(response_body, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
throw std::runtime_error("响应不是合法 JSON: " + response_body.substr(0, 200));
|
throw std::runtime_error("响应不是合法 JSON: " + response_body.substr(0, 200));
|
||||||
@@ -119,7 +121,7 @@ std::string run_chat_loop(const AgentConfig& cfg,
|
|||||||
auto args_it = fn.find("arguments");
|
auto args_it = fn.find("arguments");
|
||||||
if (args_it != fn.end() && !args_it->value().is_null()) {
|
if (args_it != fn.end() && !args_it->value().is_null()) {
|
||||||
std::string args_str = json::value_to<std::string>(args_it->value());
|
std::string args_str = json::value_to<std::string>(args_it->value());
|
||||||
json::error_code aec;
|
boost::system::error_code aec;
|
||||||
args = json::parse(args_str, aec);
|
args = json::parse(args_str, aec);
|
||||||
if (aec) args = json::object();
|
if (aec) args = json::object();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user