Skip to content

Commit 806b088

Browse files
mcjcloudhyangah
authored andcommitted
[release] src/goEnvironmentStatus.ts: ignore uninstalled Go on network failure
This CL handles errors in the network request to get uninstalled versions of Go. If there is an error, an empty result is returned rather than erroring. Fixes #438 Change-Id: Ieab81b9b4e7034066ea11a97c843a1cbf8601b88 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/245677 Reviewed-by: Hyang-Ah Hana Kim <[email protected]> (cherry picked from commit 18eaf7e) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/245643 Reviewed-by: Brayden Cloud <[email protected]>
1 parent 0828cdf commit 806b088

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/goEnvironmentStatus.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,16 @@ interface GoVersionWebResult {
433433
}
434434
async function fetchDownloadableGoVersions(): Promise<GoEnvironmentOption[]> {
435435
// fetch information about what Go versions are available to install
436-
const webResults = await WebRequest.json<GoVersionWebResult[]>('https://golang.org/dl/?mode=json');
437-
if (!webResults) {
436+
let webResults;
437+
try {
438+
webResults = await WebRequest.json<GoVersionWebResult[]>('https://golang.org/dl/?mode=json');
439+
} catch (error) {
438440
return [];
439441
}
440442

443+
if (!webResults) {
444+
return [];
445+
}
441446
// turn the web result into GoEnvironmentOption model
442447
return webResults.reduce((opts, result: GoVersionWebResult) => {
443448
// TODO: allow downloading from different sites

0 commit comments

Comments
 (0)