Added error handling for invalid RSS feed
This commit is contained in:
parent
fb129feb8f
commit
910c06415b
13
feed-bot.js
13
feed-bot.js
|
@ -27,7 +27,17 @@ bot.on("message", function (user, userID, channelID, message) {
|
|||
function checkFeedAndPost() {
|
||||
//check the feed, with a callback
|
||||
FeedRead(Config.feedUrl, function (err, articles){
|
||||
if (err) throw err;
|
||||
try{
|
||||
checkLinkAndPost(err, articles);
|
||||
}
|
||||
catch(ex){
|
||||
console.log("ERROR: " + (ex.message || ex));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function checkLinkAndPost(err, articles) {
|
||||
if (err) throw "Error reading RSS feed: " + (err.message || err);
|
||||
|
||||
var latestLink = articles[0].link;
|
||||
|
||||
|
@ -48,5 +58,4 @@ function checkFeedAndPost() {
|
|||
message: latestLink
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue