[RSS] Add catch for ServerDisconnectedError

This commit is contained in:
aikaterna
2022-01-07 11:20:55 -08:00
committed by GitHub
parent 15a93e6796
commit a361fec9b7

View File

@@ -29,7 +29,7 @@ IPV4_RE = re.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}")
IPV6_RE = re.compile("([a-f0-9:]+:+)+[a-f0-9]+")
__version__ = "1.6.4"
__version__ = "1.6.5"
class RSS(commands.Cog):
@@ -395,6 +395,11 @@ class RSS(commands.Cog):
msg = f"asyncio timeout while accessing feed at url:\n\t{url}"
log.error(msg, exc_info=True)
return None, friendly_msg
except aiohttp.client_exceptions.ServerDisconnectedError:
friendly_msg = "The target server disconnected early without a response."
msg = f"server disconnected while accessing feed at url:\n\t{url}"
log.error(msg, exc_info=True)
return None, friendly_msg
except Exception:
friendly_msg = "There was an unexpected error. Check your console for more information."
msg = f"General failure accessing feed at url:\n\t{url}"
@@ -822,9 +827,18 @@ class RSS(commands.Cog):
"That seems to be an invalid URL. Use a full website URL like `https://www.site.com/`."
)
return
except aiohttp.client_exceptions.ServerDisconnectedError:
await ctx.send("The server disconnected early without a response.")
return
except asyncio.exceptions.TimeoutError:
await ctx.send("The site didn't respond in time or there was no response.")
return
except Exception as e:
msg = "There was an issue trying to find a feed in that site. "
msg += "Please check your console for more information."
log.exception(e, exc_info=e)
await ctx.send(msg)
return
if "403 Forbidden" in soup.get_text():
await ctx.send("I received a '403 Forbidden' message while trying to reach that site.")