Catch parse exception
This commit is contained in:
@@ -183,6 +183,7 @@ module.exports.downloadFile = (url, destination, progressCallback, completeCallb
|
|||||||
responseType: 'stream',
|
responseType: 'stream',
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
try {
|
||||||
const total = parseInt(response.headers['content-length'], 10);
|
const total = parseInt(response.headers['content-length'], 10);
|
||||||
if (total === 0) {
|
if (total === 0) {
|
||||||
completeCallback(Error('No data available for download'));
|
completeCallback(Error('No data available for download'));
|
||||||
@@ -216,6 +217,9 @@ module.exports.downloadFile = (url, destination, progressCallback, completeCallb
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
completeCallback(error);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
completeCallback(error);
|
completeCallback(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user