mirror of
https://github.com/mempool/mempool.git
synced 2024-11-19 09:52:14 +01:00
Throw error when failing to download json assets.
This commit is contained in:
parent
3b546b234f
commit
16603e4fc1
@ -7,9 +7,14 @@ if (process.argv[2] && process.argv[2] === 'dev') {
|
||||
}
|
||||
|
||||
function download(filename, url) {
|
||||
var file = fs.createWriteStream(filename);
|
||||
https.get(url, function(response) {
|
||||
response.pipe(file);
|
||||
https.get(url, (response) => {
|
||||
if (response.statusCode < 200 || response.statusCode > 299) {
|
||||
throw new Error('HTTP Error ' + response.statusCode + ' while fetching \'' + filename + '\'');
|
||||
}
|
||||
response.pipe(fs.createWriteStream(filename));
|
||||
})
|
||||
.on('error', function(e) {
|
||||
throw new Error(e);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user