This commit is contained in:
Vito0912 2025-03-17 20:04:01 +01:00
parent 9b79aab4d5
commit 3c9966e849
No known key found for this signature in database
GPG key ID: 29A3D509FE70B237
2 changed files with 25 additions and 14 deletions

View file

@ -123,3 +123,20 @@ module.exports.zipDirectoriesPipe = (paths, filename, res) => {
archive.finalize()
})
}
/**
* Handles errors that occur during the download process.
*
* @param error
* @param res
* @returns {*}
*/
module.exports.handleDownloadError = (error, res) => {
if (!res.headersSent) {
if (error.code === 'ENOENT') {
return res.status(404).send('File not found')
} else {
return res.status(500).send('Download failed')
}
}
}