Skip to content

Commit

Permalink
src/goEnvironmentStatus.ts: ignore uninstalled Go on network failure
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mcjcloud authored and hyangah committed Jul 29, 2020
1 parent fe3c6b5 commit 18eaf7e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/goEnvironmentStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,16 @@ interface GoVersionWebResult {
}
async function fetchDownloadableGoVersions(): Promise<GoEnvironmentOption[]> {
// fetch information about what Go versions are available to install
const webResults = await WebRequest.json<GoVersionWebResult[]>('https://golang.org/dl/?mode=json');
if (!webResults) {
let webResults;
try {
webResults = await WebRequest.json<GoVersionWebResult[]>('https://golang.org/dl/?mode=json');
} catch (error) {
return [];
}

if (!webResults) {
return [];
}
// turn the web result into GoEnvironmentOption model
return webResults.reduce((opts, result: GoVersionWebResult) => {
// TODO: allow downloading from different sites
Expand Down

0 comments on commit 18eaf7e

Please sign in to comment.