From 43cb8556b46173b11092cef868c8d857afa1d408 Mon Sep 17 00:00:00 2001 From: spebl Date: Wed, 15 Jan 2025 16:20:24 -0800 Subject: [PATCH] wrap proposed API call in try/catch --- Extension/src/LanguageServer/extension.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index 5e759f06d8..87ac5d6e57 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -1430,14 +1430,21 @@ async function onCopilotHover(): Promise { // Gather the content for the query from the client. const requestInfo = await copilotHoverProvider.getRequestInfo(hoverDocument, hoverPosition); - for (const file of requestInfo.files) { - const fileUri = vscode.Uri.file(file); - if (await vscodelm.fileIsIgnored(fileUri, copilotHoverProvider.getCurrentHoverCancellationToken() ?? CancellationToken.None)) { - telemetry.logLanguageServerEvent("CopilotHover", { "Message": "Copilot summary is not available due to content exclusion." }); - await showCopilotContent(copilotHoverProvider, hoverDocument, hoverPosition, localize("copilot.hover.unavailable", "Copilot summary is not available.") + "\n\n" + - localize("copilot.hover.excluded", "The file containing this symbol's definition or declaration has been excluded from use with Copilot.")); - return; + try { + for (const file of requestInfo.files) { + const fileUri = vscode.Uri.file(file); + if (await vscodelm.fileIsIgnored(fileUri, copilotHoverProvider.getCurrentHoverCancellationToken() ?? CancellationToken.None)) { + telemetry.logLanguageServerEvent("CopilotHover", { "Message": "Copilot summary is not available due to content exclusion." }); + await showCopilotContent(copilotHoverProvider, hoverDocument, hoverPosition, localize("copilot.hover.unavailable", "Copilot summary is not available.") + "\n\n" + + localize("copilot.hover.excluded", "The file containing this symbol's definition or declaration has been excluded from use with Copilot.")); + return; + } } + } catch (err) { + if (err instanceof Error) { + await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, err.message); + } + return; } if (requestInfo.content.length === 0) { // Context is not available for this symbol.