@@ -24,19 +24,34 @@ namespace PythonInstallation {
2424 }
2525
2626 // Consider third party file system providers
27- const pythonRepositoryUri = Uri . parse ( pythonRepository ) ;
28- if ( ! isGithubUri ( pythonRepositoryUri ) ) {
29- const binaryLocation = Uri . joinPath ( pythonRepositoryUri , 'python.wasm' ) ;
27+ try {
28+ let pythonRepositoryUri : Uri | undefined = undefined ;
3029 try {
31- // fs.stat throws if file doesn't exist
32- await workspace . fs . stat ( binaryLocation ) ;
33- Tracer . append ( `Using python library from ${ pythonRepositoryUri } ` ) ;
34- return { repository : pythonRepositoryUri , root : '/' } ;
35- } catch {
36- Tracer . append ( `python.wasm not found in ${ binaryLocation } . Falling back to default repository` ) ;
37- pythonRepository = defaultPythonRepository ;
38- pythonRoot = defaultPythonRoot ;
30+ // Uri.parse throws if the URI is invalid
31+ pythonRepositoryUri = Uri . parse ( pythonRepository ) ;
32+ }
33+ catch ( e ) {
34+ Tracer . append ( `${ pythonRepository } is not a valid URI` ) ;
35+ throw e ;
36+ }
37+
38+ if ( ! isGithubUri ( pythonRepositoryUri ) ) {
39+ const binaryLocation = Uri . joinPath ( pythonRepositoryUri , 'python.wasm' ) ;
40+ try {
41+ // fs.stat throws if file doesn't exist
42+ await workspace . fs . stat ( binaryLocation ) ;
43+ Tracer . append ( `Using python library from ${ pythonRepositoryUri } ` ) ;
44+
45+ return { repository : pythonRepositoryUri , root : '/' } ;
46+ } catch ( e ) {
47+ Tracer . append ( `python.wasm not found in ${ binaryLocation } ` ) ;
48+ throw e ;
49+ }
3950 }
51+ } catch {
52+ Tracer . append ( `Falling back to default repository` ) ;
53+ pythonRepository = defaultPythonRepository ;
54+ pythonRoot = defaultPythonRoot ;
4055 }
4156
4257 const extname = path . extname ( pythonRepository ) ;
0 commit comments