@@ -211,7 +211,15 @@ function isRateLimit(input: any): input is RateLimit {
211211async function getRateLimit ( ) : Promise < RateLimit > {
212212 const header : OutgoingHttpHeaders = { 'User-Agent' : 'vscode-cpptools' } ;
213213 const data : string = await util . downloadFileToStr ( 'https://api.github.com/rate_limit' , header )
214- . catch ( ( ) => { throw new Error ( 'Failed to download rate limit JSON' ) ; } ) ;
214+ . catch ( ( error ) => {
215+ if ( error . code && error . code !== "ENOENT" ) {
216+ // Only throw if the user is connected to the Internet.
217+ throw new Error ( 'Failed to download rate limit JSON' ) ;
218+ }
219+ } ) ;
220+ if ( ! data ) {
221+ return Promise . resolve ( null ) ;
222+ }
215223
216224 let rateLimit : any ;
217225 try {
@@ -229,7 +237,7 @@ async function getRateLimit(): Promise<RateLimit> {
229237
230238async function rateLimitExceeded ( ) : Promise < boolean > {
231239 const rateLimit : RateLimit = await getRateLimit ( ) ;
232- return rateLimit . rate . remaining <= 0 ;
240+ return rateLimit && rateLimit . rate . remaining <= 0 ;
233241}
234242
235243/**
@@ -246,7 +254,15 @@ async function getReleaseJson(): Promise<Build[]> {
246254 const header : OutgoingHttpHeaders = { 'User-Agent' : 'vscode-cpptools' } ;
247255
248256 const data : string = await util . downloadFileToStr ( releaseUrl , header )
249- . catch ( ( ) => { throw new Error ( 'Failed to download release JSON' ) ; } ) ;
257+ . catch ( ( error ) => {
258+ if ( error . code && error . code !== "ENOENT" ) {
259+ // Only throw if the user is connected to the Internet.
260+ throw new Error ( 'Failed to download release JSON' ) ;
261+ }
262+ } ) ;
263+ if ( ! data ) {
264+ return Promise . resolve ( null ) ;
265+ }
250266
251267 // Parse the file
252268 let releaseJson : any ;
0 commit comments