add some more error handlers
This commit is contained in:
parent
5f7b7c340f
commit
6f1fdf6d87
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user