add some more error handlers
This commit is contained in:
parent
5f7b7c340f
commit
6f1fdf6d87
@ -20,7 +20,11 @@ function errorMessage(error, code, extra) {
|
|||||||
console.log(error.code)
|
console.log(error.code)
|
||||||
if (code == "404") {
|
if (code == "404") {
|
||||||
var error = "[04ERROR] 404: " + extra + " not found"
|
var error = "[04ERROR] 404: " + extra + " not found"
|
||||||
} else {
|
} else if (error.code == "ECONNREFUSED") {
|
||||||
|
var error = "[04ERROR] Connection Refused"
|
||||||
|
} else if (error.code == "ERR_UNESCAPED_CHARACTERS"){
|
||||||
|
var error = "[04ERROR] Unescaped Characters"
|
||||||
|
} else {
|
||||||
var error = "[04ERROR] Unknown error"
|
var error = "[04ERROR] Unknown error"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +37,11 @@ async function fetchFeed(feedURL, n) {
|
|||||||
try {
|
try {
|
||||||
var newFeed = await parser.parseURL(feedURL);
|
var newFeed = await parser.parseURL(feedURL);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errorMessage(e, "404", feedURL);
|
if (e.code !== undefined) {
|
||||||
|
errorMessage(e)
|
||||||
|
} else {
|
||||||
|
errorMessage(e, "404", feedURL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (n > newFeed.items.length) {
|
if (n > newFeed.items.length) {
|
||||||
var n = newFeed.items.length;
|
var n = newFeed.items.length;
|
||||||
|
@ -20,7 +20,11 @@ function errorMessage(error, code, extra) {
|
|||||||
console.log(error.code)
|
console.log(error.code)
|
||||||
if (code == "404") {
|
if (code == "404") {
|
||||||
var error = "[04ERROR] 404: " + extra + " not found"
|
var error = "[04ERROR] 404: " + extra + " not found"
|
||||||
} else {
|
} else if (error.code == "ECONNREFUSED") {
|
||||||
|
var error = "[04ERROR] Connection Refused"
|
||||||
|
} else if (error.code == "ERR_UNESCAPED_CHARACTERS"){
|
||||||
|
var error = "[04ERROR] Unescaped Characters"
|
||||||
|
} else {
|
||||||
var error = "[04ERROR] Unknown error"
|
var error = "[04ERROR] Unknown error"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +43,11 @@ async function fetchFeed(feedURL, n) {
|
|||||||
try {
|
try {
|
||||||
var newFeed = await parser.parseURL(feedURL);
|
var newFeed = await parser.parseURL(feedURL);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errorMessage(e, "404", feedURL);
|
if (e.code !== undefined) {
|
||||||
|
errorMessage(e)
|
||||||
|
} else {
|
||||||
|
errorMessage(e, "404", feedURL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n > newFeed.items.length) {
|
if (n > newFeed.items.length) {
|
||||||
|
Loading…
Reference in New Issue
Block a user