@@ -224,8 +224,9 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildR
224224 options . config . proxy = false ;
225225 options . config . httpAgent = new HttpsProxyAgent ( process . env . HTTPS_PROXY ) ;
226226 }
227+ let response ;
227228 try {
228- const response = await axios . get ( options . url , options . config ) ;
229+ response = await axios . get ( options . url , options . config ) ;
229230 buildDetails = response . data ;
230231 if ( response . status != 200 ) {
231232 logger . error ( 'Downloading the build artifacts failed.' ) ;
@@ -264,7 +265,18 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildR
264265 logger . error ( `Error: Request failed with status code ${ err . status } ` )
265266 logger . error ( utils . formatRequest ( err . status , err . response , err . response . data ) ) ;
266267 } else {
267- logger . info ( err ) ;
268+ messageType = Constants . messageTypes . ERROR ;
269+ errorCode = 'api_failed_build_artifacts' ;
270+ if ( BUILD_ARTIFACTS_FAIL_COUNT > 0 ) {
271+ messageType = Constants . messageTypes . ERROR ;
272+ message = Constants . userMessages . DOWNLOAD_BUILD_ARTIFACTS_FAILED . replace ( '<build-id>' , buildId ) . replace ( '<machine-count>' , BUILD_ARTIFACTS_FAIL_COUNT ) ;
273+ logger . error ( message ) ;
274+ } else {
275+ logger . error ( 'Downloading the build artifacts failed.' ) ;
276+ }
277+ utils . sendUsageReport ( bsConfig , args , err , messageType , errorCode , buildReportData , rawArgs ) ;
278+ logger . error ( `Error: Request failed with status code ${ response . status } ` )
279+ logger . error ( utils . formatRequest ( err , response , response . data ) ) ;
268280 }
269281 process . exitCode = Constants . ERROR_EXIT_CODE ;
270282 }
0 commit comments