Add more error handling

This commit is contained in:
the1812 2019-04-23 21:42:26 +08:00
parent 3526053faf
commit 8a8e165908
3 changed files with 10 additions and 10 deletions

View File

@ -1,6 +1,6 @@
{
"name": "bilibili-evolved-video-link-downloader",
"version": "1.7.28.0",
"version": "1.7.28.1",
"description": "Bilibili Evolved 视频链接下载器",
"main": "video-link-downloader.js",
"bin": {

View File

@ -71,10 +71,10 @@ class Downloader {
this.progressMap.set(req, this.progressMap.get(req) + data.length);
this.updateProgress();
}).on("error", error => {
this.progressMap.set(req, 0);
this.progressMap.delete(req);
this.progressMap.set(makeRequest(), 0);
this.updateProgress();
// makeRequest();
console.error(error);
console.error(`片段下载失败: ${error} 重试中...`);
});
req.pipe(fs.createWriteStream(`${title}.part${part}`));
return req;
@ -132,7 +132,7 @@ class Downloader {
inputData = JSON.parse(jsonText);
}
catch (error) {
console.log(`未在剪贴板检测到有效数据, 也没有指定输入文件.`);
console.log(`[无数据] 未在剪贴板检测到有效数据/没有指定输入文件/输入文件的数据无效.`);
process.exit();
}
try {

View File

@ -99,10 +99,10 @@ class Downloader
this.updateProgress();
}).on("error", error =>
{
this.progressMap.set(req, 0);
this.progressMap.delete(req);
this.progressMap.set(makeRequest(), 0);
this.updateProgress();
// makeRequest();
console.error(error);
console.error(`片段下载失败: ${error} 重试中...`);
});
req.pipe(fs.createWriteStream(`${title}.part${part}`));
return req;
@ -173,7 +173,7 @@ class Downloader
}
catch (error)
{
console.log(`未在剪贴板检测到有效数据, 也没有指定输入文件.`);
console.log(`[无数据] 未在剪贴板检测到有效数据/没有指定输入文件/输入文件的数据无效.`);
process.exit();
}
try