From 04e26185ab5351e134053fc6e8bb3a42a8719cb3 Mon Sep 17 00:00:00 2001 From: Ovidiu Rusu Date: Thu, 31 Oct 2024 15:38:00 +0200 Subject: [PATCH] Catch errors in case there are any when retrieving package or tool data --- .../sema4ai_code/robocorp_language_server.py | 6 ---- sema4ai/vscode-client/src/rcc.ts | 32 +++++++++++++------ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/sema4ai/src/sema4ai_code/robocorp_language_server.py b/sema4ai/src/sema4ai_code/robocorp_language_server.py index 632db9e7..f026a202 100644 --- a/sema4ai/src/sema4ai_code/robocorp_language_server.py +++ b/sema4ai/src/sema4ai_code/robocorp_language_server.py @@ -1809,12 +1809,6 @@ def _agent_cli_version(self, download_if_missing=True) -> ActionResultDict: download_if_missing=download_if_missing ).as_dict() - def m_action_server_version(self, download_if_missing=True) -> ActionResultDict: - return self._action_server_version(download_if_missing=download_if_missing) - - def m_agent_cli_version(self, download_if_missing=True) -> ActionResultDict: - return self._agent_cli_version(download_if_missing=download_if_missing) - @command_dispatcher(commands.SEMA4AI_CREATE_AGENT_PACKAGE_INTERNAL) def _create_agent_package( self, params: CreateAgentPackageParamsDict diff --git a/sema4ai/vscode-client/src/rcc.ts b/sema4ai/vscode-client/src/rcc.ts index 9284e30f..222fea9b 100644 --- a/sema4ai/vscode-client/src/rcc.ts +++ b/sema4ai/vscode-client/src/rcc.ts @@ -4,7 +4,7 @@ import * as pathModule from "path"; import * as os from "os"; import { configure as configureXHR } from "./requestLight"; import { fileExists, getExtensionRelativeFile } from "./files"; -import { CancellationToken, extensions, Progress, ProgressLocation, window, workspace } from "vscode"; +import { CancellationToken, commands, extensions, Progress, ProgressLocation, window, workspace } from "vscode"; import { logError, OUTPUT_CHANNEL } from "./channel"; import { Timing } from "./time"; import { execFilePromise, ExecFileReturn, mergeEnviron } from "./subprocess"; @@ -14,6 +14,7 @@ import { runAsAdminWin32 } from "./extensionCreateEnv"; import { GLOBAL_STATE, langServer } from "./extension"; import { downloadWithProgress, DownloadProgress } from "./http"; import * as roboCommands from "./robocorpCommands"; +import { ActionResult } from "./protocols"; let lastPrintedRobocorpHome: string = ""; @@ -454,12 +455,16 @@ async function collectToolsVersions(rccLocation: string): Promise { const rccVersion: any = await execFilePromise(rccLocation, ["--version"], {}); toolsVersions["rcc"] = rccVersion.stdout.trim(); - const actionServerVersion: any = await langServer.sendRequest("actionServerVersion", { - download_if_missing: false, - }); + const actionServerVersion: ActionResult = await commands.executeCommand( + roboCommands.SEMA4AI_ACTION_SERVER_VERSION_INTERNAL, + { download_if_missing: false } + ); toolsVersions["action-server"] = actionServerVersion?.result?.trim() || ""; - const agentCliVersion: any = await langServer.sendRequest("agentCliVersion", { download_if_missing: false }); + const agentCliVersion: ActionResult = await commands.executeCommand( + roboCommands.SEMA4AI_AGENT_CLI_VERSION_INTERNAL, + { download_if_missing: false } + ); toolsVersions["action-cli"] = agentCliVersion?.result?.trim() || ""; return toolsVersions; @@ -486,12 +491,21 @@ export async function submitIssue( const metadata = await collectIssueBaseMetadata(); - const currentPackages: any = await langServer.sendRequest("listRobots"); - const toolsVersions: any = await collectToolsVersions(rccLocation); + try { + const currentPackages: any = await langServer.sendRequest("listRobots"); + metadata["packages"] = currentPackages.result; + } catch (error) { + metadata["packages"] = `Error retrieving robot packages: ${error.message || error}`; + } + + try { + const toolsVersions: any = await collectToolsVersions(rccLocation); + metadata["tools"] = toolsVersions; + } catch (error) { + metadata["tools"] = `Error retrieving tools versions: ${error.message || error}`; + } // Add required metadata info from parameters. - metadata["tools"] = toolsVersions; - metadata["packages"] = currentPackages.result; metadata["dialogMessage"] = dialogMessage; metadata["email"] = email; metadata["errorName"] = errorName;