add some more error handlers

This commit is contained in:
hgw 2023-10-02 02:11:25 +00:00
parent 5f7b7c340f
commit 6f1fdf6d87
2 changed files with 20 additions and 4 deletions

View File

@ -20,6 +20,10 @@ function errorMessage(error, code, extra) {
console.log(error.code)
if (code == "404") {
var error = "[04ERROR] 404: " + extra + " not found"
} 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"
}
@ -33,8 +37,12 @@ async function fetchFeed(feedURL, n) {
try {
var newFeed = await parser.parseURL(feedURL);
} catch (e) {
if (e.code !== undefined) {
errorMessage(e)
} else {
errorMessage(e, "404", feedURL);
}
}
if (n > newFeed.items.length) {
var n = newFeed.items.length;
content.push("[08WARNING] Your requested post amount exceeded the total available. Reverting to " + newFeed.items.length);

View File

@ -20,6 +20,10 @@ function errorMessage(error, code, extra) {
console.log(error.code)
if (code == "404") {
var error = "[04ERROR] 404: " + extra + " not found"
} 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"
}
@ -39,8 +43,12 @@ async function fetchFeed(feedURL, n) {
try {
var newFeed = await parser.parseURL(feedURL);
} catch (e) {
if (e.code !== undefined) {
errorMessage(e)
} else {
errorMessage(e, "404", feedURL);
}
}
if (n > newFeed.items.length) {
var n = newFeed.items.length;