From 990647a104d537b67b00ed2e29870a035124a3fd Mon Sep 17 00:00:00 2001 From: Chris Sidi Date: Thu, 26 Nov 2020 01:16:06 -0500 Subject: [PATCH] More error handling --- .../src/internal/download-http-client.ts | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/artifact/src/internal/download-http-client.ts b/packages/artifact/src/internal/download-http-client.ts index 3b00872e..64631c5c 100644 --- a/packages/artifact/src/internal/download-http-client.ts +++ b/packages/artifact/src/internal/download-http-client.ts @@ -263,12 +263,20 @@ export class DownloadHttpClient { if (isGzip) { const gunzip = zlib.createGunzip() response.message + .on('error', error => { + core.error( + `An error occurred while attempting to read the response stream` + ) + reject(error) + gunzip.close() + }) .pipe(gunzip) .on('error', error => { core.error( - `An error has been encountered while attempting to decompress a file` + `An error occurred while attempting to decompress the response stream` ) reject(error) + destinationStream.close() }) .pipe(destinationStream) .on('close', () => { @@ -276,19 +284,26 @@ export class DownloadHttpClient { }) .on('error', error => { core.error( - `An error has been encountered while decompressing and writing a downloaded file to ${destinationStream.path}` + `An error occurred while writing a downloaded file to ${destinationStream.path}` ) reject(error) }) } else { response.message + .on('error', error => { + core.error( + `An error occurred while attempting to read the response stream` + ) + reject(error) + destinationStream.close() + }) .pipe(destinationStream) .on('close', () => { resolve() }) .on('error', error => { core.error( - `An error has been encountered while writing a downloaded file to ${destinationStream.path}` + `An error occurred while writing a downloaded file to ${destinationStream.path}` ) reject(error) })