Skip to content

Commit 0ec4890

Browse files
committed
dont log error for symbols with no context and dont log generic error message in failure case
1 parent e083fa3 commit 0ec4890

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Extension/src/LanguageServer/extension.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,9 @@ async function onCopilotHover(): Promise<void> {
14311431
// Gather the content for the query from the client.
14321432
const requestInfo = await copilotHoverProvider.getRequestInfo(hoverDocument, hoverPosition);
14331433
if (requestInfo.length === 0) {
1434-
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, "Failed to receive request info from the client.");
1434+
// Context is not available for this symbol.
1435+
telemetry.logLanguageServerEvent("CopilotHover", { "Message": "Copilot summary is not available for this symbol." });
1436+
await showCopilotContent(copilotHoverProvider, hoverDocument, hoverPosition, localize("copilot.hover.unavailable", "Copilot summary is not available for this symbol."));
14351437
return;
14361438
}
14371439

@@ -1462,7 +1464,7 @@ async function onCopilotHover(): Promise<void> {
14621464

14631465
// Ensure we have a valid response from Copilot.
14641466
if (!chatResponse) {
1465-
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition);
1467+
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, "Invalid chat response from Copilot.");
14661468
return;
14671469
}
14681470

@@ -1481,15 +1483,14 @@ async function onCopilotHover(): Promise<void> {
14811483
}
14821484

14831485
if (content.length === 0) {
1484-
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition);
1486+
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, "No content in response from Copilot.");
14851487
return;
14861488
}
14871489

14881490
await showCopilotContent(copilotHoverProvider, hoverDocument, hoverPosition, content);
14891491
}
14901492

1491-
async function reportCopilotFailure(copilotHoverProvider: CopilotHoverProvider, hoverDocument: vscode.TextDocument, hoverPosition: vscode.Position, customError?: string): Promise<void> {
1492-
const errorMessage = customError ? customError : "";
1493+
async function reportCopilotFailure(copilotHoverProvider: CopilotHoverProvider, hoverDocument: vscode.TextDocument, hoverPosition: vscode.Position, errorMessage: string): Promise<void> {
14931494
telemetry.logLanguageServerEvent("CopilotHoverError", { "ErrorMessage": errorMessage });
14941495
// Display the localized default failure message in the hover.
14951496
await showCopilotContent(copilotHoverProvider, hoverDocument, hoverPosition, localize("copilot.hover.error", "An error occurred while generating Copilot summary."));

0 commit comments

Comments
 (0)