Tidy up some feed error spam

This commit is contained in:
benji7425 2017-12-03 16:04:10 +00:00
parent 987473ffa6
commit 18f300d46d
3 changed files with 10 additions and 7 deletions

View File

@ -1,6 +1,8 @@
# Changelog
## Unreleased
### Updated
- Tidy up some console spam
### Fixed
- Fix bot crash if feed article contains link with invalid host name
- Temporary fix for bot crash if used with a feed without links in the articles (didn't realise this was possible...)

View File

@ -54,7 +54,7 @@ module.exports = class FeedData {
fetchLatest(guild) {
Dns.resolve(Url.parse(this.url).host || "", err => {
if (err)
DiscordUtil.dateError("Connection Error: Can't resolve host", err.message || err);
DiscordUtil.dateDebugError("Connection Error: Can't resolve host", err.message || err);
else
this._doFetchRSS(guild);
});
@ -67,12 +67,8 @@ module.exports = class FeedData {
_doFetchRSS(guild) {
FeedRead(this.url, (err, articles) => {
//filter out "Body is not RSS or ATOM" errors because these seem to happen rather frequently
if (err) {
if (err.message !== "Body is not RSS or ATOM")
DiscordUtil.dateError("Error reading RSS feed: " + (err.message || err));
if (err)
return;
}
if (articles.length > 0 && articles[0].link) {
@ -85,7 +81,7 @@ module.exports = class FeedData {
role = guild.roles.get(this.roleID);
channel.send((role || "") + formatPost(articles[0]))
.catch(err => DiscordUtil.dateError(`Error posting in ${channel.id}: ${err.message || err}`));
.catch(err => DiscordUtil.dateDebugError(`Error posting in ${channel.id}: ${err.message || err}`));
}
}
});

View File

@ -30,6 +30,10 @@ function dateError(...args) {
doDateLog(Console.error, logWriter, args, "ERROR");
}
function dateDebugError(...args) {
doDateLog(null, null, args, "DEBUG ERROR");
}
function dateDebug(...args) {
doDateLog(null, null, args, "DEBUG");
}
@ -58,5 +62,6 @@ module.exports = {
dateError,
dateLog,
dateDebug,
dateDebugError,
ask
};