Skip to content

Commit

Permalink
More error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hashtagchris authored and yacaovsnc committed Dec 3, 2020
1 parent 520206f commit 990647a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/artifact/src/internal/download-http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,32 +263,47 @@ 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', () => {
resolve()
})
.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)
})
Expand Down

0 comments on commit 990647a

Please sign in to comment.