File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -565,6 +565,10 @@ export class PermissionsError extends ToolkitError {
565565}
566566
567567export function isNetworkError ( err ?: unknown ) : err is Error & { code : string } {
568+ if ( isVSCodeProxyError ( err ) ) {
569+ return true
570+ }
571+
568572 if ( ! hasCode ( err ) ) {
569573 return false
570574 }
@@ -584,3 +588,17 @@ export function isNetworkError(err?: unknown): err is Error & { code: string } {
584588 'EADDRNOTAVAIL' , // port not available/allowed?
585589 ] . includes ( err . code )
586590}
591+
592+ /**
593+ * This error occurs on a network call if the user has set up a proxy in the
594+ * VS Code settings but the proxy is not reachable.
595+ *
596+ * Setting ID: http.proxy
597+ */
598+ function isVSCodeProxyError ( err ?: unknown ) : boolean {
599+ if ( ! ( err instanceof Error ) ) {
600+ return false
601+ }
602+
603+ return err . name === 'Error' && err . message . startsWith ( 'Failed to establish a socket connection to proxies' )
604+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111 getErrorMsg ,
1212 getTelemetryReason ,
1313 getTelemetryResult ,
14+ isNetworkError ,
1415 resolveErrorMessageToDisplay ,
1516 ToolkitError ,
1617} from '../../shared/errors'
@@ -416,4 +417,17 @@ describe('util', function () {
416417 ; ( err as any ) . error_description = 'aws error desc 1'
417418 assert . deepStrictEqual ( getErrorMsg ( err ) , 'aws error desc 1' )
418419 } )
420+
421+ it ( 'isNetworkError()' , function ( ) {
422+ assert . deepStrictEqual (
423+ isNetworkError ( new Error ( 'Failed to establish a socket connection to proxies BLAH BLAH BLAH' ) ) ,
424+ true ,
425+ 'Did not return "true" on a VS Code Proxy error'
426+ )
427+ assert . deepStrictEqual (
428+ isNetworkError ( new Error ( 'I am NOT a network error' ) ) ,
429+ false ,
430+ 'Incorrectly indicated as network error'
431+ )
432+ } )
419433} )
You can’t perform that action at this time.
0 commit comments