Skip to content

Commit

Permalink
wrap proposed API call in try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
spebl committed Jan 16, 2025
1 parent 792d8f9 commit 43cb855
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1430,14 +1430,21 @@ async function onCopilotHover(): Promise<void> {

// 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.
Expand Down

0 comments on commit 43cb855

Please sign in to comment.