@@ -72,15 +72,36 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) {
72
72
const downloadUrl = release . files [ 0 ] . download_url ;
73
73
74
74
core . info ( `Download from "${ downloadUrl } "` ) ;
75
- const pythonPath = await tc . downloadTool ( downloadUrl , undefined , AUTH ) ;
76
- core . info ( 'Extract downloaded archive' ) ;
77
- let pythonExtractedFolder ;
78
- if ( IS_WINDOWS ) {
79
- pythonExtractedFolder = await tc . extractZip ( pythonPath ) ;
80
- } else {
81
- pythonExtractedFolder = await tc . extractTar ( pythonPath ) ;
82
- }
75
+ let pythonPath = '' ;
76
+ try {
77
+ pythonPath = await tc . downloadTool ( downloadUrl , undefined , AUTH ) ;
78
+ core . info ( 'Extract downloaded archive' ) ;
79
+ let pythonExtractedFolder ;
80
+ if ( IS_WINDOWS ) {
81
+ pythonExtractedFolder = await tc . extractZip ( pythonPath ) ;
82
+ } else {
83
+ pythonExtractedFolder = await tc . extractTar ( pythonPath ) ;
84
+ }
83
85
84
- core . info ( 'Execute installation script' ) ;
85
- await installPython ( pythonExtractedFolder ) ;
86
+ core . info ( 'Execute installation script' ) ;
87
+ await installPython ( pythonExtractedFolder ) ;
88
+ } catch ( err ) {
89
+ if ( err instanceof Error )
90
+ {
91
+ // Rate limit?
92
+ if (
93
+ err instanceof tc . HTTPError &&
94
+ ( err . httpStatusCode === 403 || err . httpStatusCode === 429 )
95
+ ) {
96
+ core . info (
97
+ `Received HTTP status code ${ err . httpStatusCode } . This usually indicates the rate limit has been exceeded`
98
+ ) ;
99
+ } else {
100
+ core . info ( err . message ) ;
101
+ }
102
+ if ( err . stack !== undefined ) {
103
+ core . debug ( err . stack ) ;
104
+ }
105
+ }
106
+ }
86
107
}
0 commit comments