Skip to content

Commit 374f177

Browse files
author
Zakaria RACHEDI
committed
New catching errors method
1 parent b87c866 commit 374f177

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lib/getItems.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,21 @@ function getData(url, back, callback) {
105105
console.log('\x1b[33m%s\x1b[0m' ,'\n Error 404 detected ! Maybe empty item (Encyclopedia error).');
106106
callback();
107107
}else if(err.statusCode == '429') {
108-
console.log('\x1b[31m%s\x1b[0m' ,'\n /!\\ Error 429 detected ! Too many request, be careful Ankama can ban your IP. /!\\ Never parse more than 700 items/hour');
108+
console.log('\x1b[31m%s\x1b[0m' ,'\n/!\\Error 429 detected ! You reached maximum request per hour, over pass it will provoke a ban IP from Ankama. Resume the parsing after 1h !');
109109
limitCrossed(gCategory, currentPosition, gLinks, itemsList);
110-
}else if(err.statusCode == 'ETIMEDOUT') {
111-
console.log('\x1b[31m%s\x1b[0m' ,'\n /!\\ Error ETIMEDOUT detected !');
110+
}else if(err.code == 'ETIMEDOUT') {
111+
console.log('\x1b[31m%s\x1b[0m' ,'\n /!\\ Error ETIMEDOUT detected ! Your connexion took too much time to respond');
112112
limitCrossed(gCategory, currentPosition, gLinks, itemsList);
113-
}else if(err.statusCode == 'ECONNRESET') {
114-
console.log('\x1b[31m%s\x1b[0m' ,'\n /!\\ Error ECONNRESET detected !');
113+
}else if(err.message == 'Error: read ECONNRESET') {
114+
console.log('\x1b[31m%s\x1b[0m' ,'\n /!\\ Error ECONNRESET detected ! Connexion shutdown or reset, verify your internet connexion !');
115+
limitCrossed(gCategory, currentPosition, gLinks, itemsList);
116+
}else if(err.message == 'Error: unable to verify the first certificate') {
117+
console.log('\x1b[31m%s\x1b[0m' ,'\n /!\\ Error ECONNABORTED detected ! Connexion shutdown, verify your internet connexion !');
115118
limitCrossed(gCategory, currentPosition, gLinks, itemsList);
116119
}else {
117120
console.log(err);
118121
console.log('\x1b[31m%s\x1b[0m' ,'/!\\Broken promise all');
119122
limitCrossed(gCategory, currentPosition, gLinks, itemsList);
120-
// process.exit();
121123
}
122124
});
123125
}
@@ -132,9 +134,8 @@ function limitCrossed(category, lastIndex, links, items) {
132134
if (err) console.log(err);
133135
fsPath.writeFile('./data/links/resume.json', JSON.stringify(resume), function(err){
134136
if (err) console.log(err);
135-
console.log('\x1b[31m%s\x1b[0m' ,'\n/!\\You reached maximum request per hour, over pass it will provoke a ban IP from Ankama. Resume the parsing after 1h !');
137+
console.log('\x1b[33m%s\x1b[0m' ,'/!\\However, don\'t worry: the app will resume the parsing from last item parsed ;)');
136138
console.log('\x1b[33m%s\x1b[0m' ,'\n INFO : ' +items.length+ ' item(s) were crawled.');
137-
console.log('\x1b[33m%s\x1b[0m' ,'/!\\Don\'t worry, the app will resume the parsing from last item parsed ;)');
138139
setTimeout(process.exit(),4000);
139140
});
140141
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "crawlit",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Crawl dofus encyclopedia ",
55
"main": "lib/app.js",
66
"bin": "lib/app.js",

0 commit comments

Comments
 (0)