Skip to content

Commit bf3965d

Browse files
Copilotnagilson
andcommitted
Fix OutputChannelObserver to suppress verbose error details for user-friendly exit codes
Co-authored-by: nagilson <[email protected]>
1 parent 9efe2b5 commit bf3965d

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

vscode-dotnet-runtime-library/src/EventStream/OutputChannelObserver.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import
1414
DotnetDebuggingMessage,
1515
DotnetExistingPathResolutionCompleted,
1616
DotnetInstallExpectedAbort,
17+
DotnetNonZeroInstallerExitCodeError,
1718
DotnetOfflineInstallUsed,
1819
DotnetOfflineWarning,
1920
DotnetUpgradedEvent,
@@ -22,6 +23,7 @@ import
2223
import { EventType } from './EventType';
2324
import { IEvent } from './IEvent';
2425
import { IEventStreamObserver } from './IEventStreamObserver';
26+
import { WinMacGlobalInstaller } from '../Acquisition/WinMacGlobalInstaller';
2527

2628
export class OutputChannelObserver implements IEventStreamObserver
2729
{
@@ -115,7 +117,37 @@ export class OutputChannelObserver implements IEventStreamObserver
115117
if (this.inProgressDownloads.includes(error?.install?.installId ?? ''))
116118
{
117119
this.outputChannel.appendLine(`Failed to download .NET ${error?.install?.installId}:`);
118-
this.outputChannel.appendLine(error?.error?.message);
120+
121+
// For user-friendly installer exit codes, show only the clean interpreted message
122+
if (error instanceof DotnetNonZeroInstallerExitCodeError)
123+
{
124+
const errorMessage = error?.error?.message || '';
125+
const exitCodeMatch = errorMessage.match(/The exit code it gave us: (\w+)\./);
126+
if (exitCodeMatch && WinMacGlobalInstaller.IsUserFriendlyExitCode(exitCodeMatch[1]))
127+
{
128+
// Extract just the interpreted message (everything after the exit code line)
129+
const lines = errorMessage.split('\n');
130+
if (lines.length > 1)
131+
{
132+
this.outputChannel.appendLine(lines.slice(1).join('\n'));
133+
}
134+
else
135+
{
136+
this.outputChannel.appendLine(errorMessage);
137+
}
138+
}
139+
else
140+
{
141+
// Show full error message for non-user-friendly codes
142+
this.outputChannel.appendLine(error?.error?.message);
143+
}
144+
}
145+
else
146+
{
147+
// Show full error message for non-installer errors
148+
this.outputChannel.appendLine(error?.error?.message);
149+
}
150+
119151
this.outputChannel.appendLine('');
120152

121153
this.updateDownloadIndicators(error.install?.installId);

0 commit comments

Comments
 (0)