Catch parse exception

This commit is contained in:
2019-08-27 16:34:32 -05:00
parent c1a9e6cc38
commit d70afb349b

View File

@@ -183,6 +183,7 @@ module.exports.downloadFile = (url, destination, progressCallback, completeCallb
responseType: 'stream',
})
.then(response => {
try {
const total = parseInt(response.headers['content-length'], 10);
if (total === 0) {
completeCallback(Error('No data available for download'));
@@ -216,6 +217,9 @@ module.exports.downloadFile = (url, destination, progressCallback, completeCallb
});
});
}
} catch (error) {
completeCallback(error);
}
})
.catch(error => {
completeCallback(error);