Skip to content

Commit 43cb855

Browse files
committed
wrap proposed API call in try/catch
1 parent 792d8f9 commit 43cb855

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Extension/src/LanguageServer/extension.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,14 +1430,21 @@ async function onCopilotHover(): Promise<void> {
14301430

14311431
// Gather the content for the query from the client.
14321432
const requestInfo = await copilotHoverProvider.getRequestInfo(hoverDocument, hoverPosition);
1433-
for (const file of requestInfo.files) {
1434-
const fileUri = vscode.Uri.file(file);
1435-
if (await vscodelm.fileIsIgnored(fileUri, copilotHoverProvider.getCurrentHoverCancellationToken() ?? CancellationToken.None)) {
1436-
telemetry.logLanguageServerEvent("CopilotHover", { "Message": "Copilot summary is not available due to content exclusion." });
1437-
await showCopilotContent(copilotHoverProvider, hoverDocument, hoverPosition, localize("copilot.hover.unavailable", "Copilot summary is not available.") + "\n\n" +
1438-
localize("copilot.hover.excluded", "The file containing this symbol's definition or declaration has been excluded from use with Copilot."));
1439-
return;
1433+
try {
1434+
for (const file of requestInfo.files) {
1435+
const fileUri = vscode.Uri.file(file);
1436+
if (await vscodelm.fileIsIgnored(fileUri, copilotHoverProvider.getCurrentHoverCancellationToken() ?? CancellationToken.None)) {
1437+
telemetry.logLanguageServerEvent("CopilotHover", { "Message": "Copilot summary is not available due to content exclusion." });
1438+
await showCopilotContent(copilotHoverProvider, hoverDocument, hoverPosition, localize("copilot.hover.unavailable", "Copilot summary is not available.") + "\n\n" +
1439+
localize("copilot.hover.excluded", "The file containing this symbol's definition or declaration has been excluded from use with Copilot."));
1440+
return;
1441+
}
14401442
}
1443+
} catch (err) {
1444+
if (err instanceof Error) {
1445+
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, err.message);
1446+
}
1447+
return;
14411448
}
14421449
if (requestInfo.content.length === 0) {
14431450
// Context is not available for this symbol.

0 commit comments

Comments
 (0)