fix some bugs; humanus_cli: planning flow on test

hkr04 2025-03-19 18:40:24 +08:00
parent 7f9862f91c
commit 4c95390137
1 changed files with 8 additions and 5 deletions

View File

@ -785,11 +785,14 @@ json stdio_client::send_jsonrpc(const request& req) {
if (status == std::future_status::ready) { if (status == std::future_status::ready) {
json response = response_future.get(); json response = response_future.get();
if (response.contains("isError") && response["isError"].get<bool>()) { if (response.contains("isError") && response["isError"].is_boolean() && response["isError"].get<bool>()) {
int code = response["error"]["code"]; if (response.contains("error") && response["error"].is_object()) {
std::string message = response["error"]["message"]; const auto& err_obj = response["error"];
int code = err_obj.contains("code") ? err_obj["code"].get<int>() : static_cast<int>(error_code::internal_error);
throw mcp_exception(static_cast<error_code>(code), message); std::string message = err_obj.value("message", "");
// Handle error
throw mcp_exception(static_cast<error_code>(code), message);
}
} }
return response; return response;