Catch all exceptions there

This commit is contained in:
Luke Murphy 2021-01-23 23:55:46 +01:00
parent d41d0a4e39
commit 745a561409
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 8 additions and 1 deletions

View File

@ -609,11 +609,18 @@ class Bot(ClientXMPP):
def serve_web(self):
"""Serve the web."""
try:
from aiohttp.web import Application, get, run_app
except ModuleNotFoundError:
print("Missing required dependency: aiohttp")
print("Have you tried `pip install xbotlib[web]`")
exit(1)
self.web = Application()
try:
self.web.add_routes([get("/", self.serve)])
except AttributeError:
except Exception:
self.web.add_routes([get("/", self.default_serve)])
self.log.info(f"Serving on http://0.0.0.0:{self.port}")