fix exception

This commit is contained in:
Terrence
2025-05-29 13:46:01 +08:00
parent 0e6375e347
commit 89fbf89d0f

View File

@@ -309,6 +309,7 @@ void McpServer::DoToolCall(int id, const std::string& tool_name, const cJSON* to
} }
PropertyList arguments = (*tool_iter)->properties(); PropertyList arguments = (*tool_iter)->properties();
try {
for (auto& argument : arguments) { for (auto& argument : arguments) {
bool found = false; bool found = false;
if (cJSON_IsObject(tool_arguments)) { if (cJSON_IsObject(tool_arguments)) {
@@ -331,6 +332,11 @@ void McpServer::DoToolCall(int id, const std::string& tool_name, const cJSON* to
return; return;
} }
} }
} catch (const std::runtime_error& e) {
ESP_LOGE(TAG, "tools/call: %s", e.what());
ReplyError(id, e.what());
return;
}
Application::GetInstance().Schedule([this, id, tool_iter, arguments = std::move(arguments)]() { Application::GetInstance().Schedule([this, id, tool_iter, arguments = std::move(arguments)]() {
try { try {