Added try catch to catch errors from parsing rss
This commit is contained in:
54
libCore.js
54
libCore.js
@@ -90,37 +90,41 @@ exports.updateFeeds = async (client) => {
|
||||
//return;
|
||||
}
|
||||
|
||||
log.DEBUG("Parsed Feed Keys", Object.keys(parsedFeed), parsedFeed?.title);
|
||||
try{
|
||||
log.DEBUG("Parsed Feed Keys", Object.keys(parsedFeed), parsedFeed?.title);
|
||||
|
||||
if (parsedFeed?.items){
|
||||
for (const post of parsedFeed.items){
|
||||
log.VERBOSE("Post from feed: ", post);
|
||||
if (post.title && post.link && post.content && ( post.postId || post.guid || post.id ) && post.pubDate){
|
||||
post.postId = post.postId ?? post.guid ?? post.id;
|
||||
postStorage.getRecordBy('post_guid', post.postId, (err, existingRecord) => {
|
||||
if (err) throw err;
|
||||
log.DEBUG("Existing post record: ", existingRecord);
|
||||
if (!existingRecord){
|
||||
const channel = client.channels.cache.get(source.channel_id);
|
||||
libUtils.sendPost(post, channel, (err, sendResults) =>{
|
||||
if (err) throw err;
|
||||
if (parsedFeed?.items){
|
||||
for (const post of parsedFeed.items){
|
||||
log.VERBOSE("Post from feed: ", post);
|
||||
if (post.title && post.link && post.content && ( post.postId || post.guid || post.id ) && post.pubDate){
|
||||
post.postId = post.postId ?? post.guid ?? post.id;
|
||||
postStorage.getRecordBy('post_guid', post.postId, (err, existingRecord) => {
|
||||
if (err) throw err;
|
||||
log.DEBUG("Existing post record: ", existingRecord);
|
||||
if (!existingRecord){
|
||||
const channel = client.channels.cache.get(source.channel_id);
|
||||
libUtils.sendPost(post, channel, (err, sendResults) =>{
|
||||
if (err) throw err;
|
||||
|
||||
if (sendResults){
|
||||
log.DEBUG("Saving post to database: ", sendResults, post.title, source.channel_id);
|
||||
if (sendResults){
|
||||
log.DEBUG("Saving post to database: ", sendResults, post.title, source.channel_id);
|
||||
|
||||
postStorage.savePost(post, (err, saveResults) => {
|
||||
if(err) throw err;
|
||||
postStorage.savePost(post, (err, saveResults) => {
|
||||
if(err) throw err;
|
||||
|
||||
if (saveResults) {
|
||||
log.DEBUG("Saved results: ", saveResults);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
if (saveResults) {
|
||||
log.DEBUG("Saved results: ", saveResults);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (err) {
|
||||
log.ERROR("Error Parsing Feed: ", source.link, err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user