From 745a561409339b05c4fab823916101cbdf67c24e Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 23 Jan 2021 23:55:46 +0100 Subject: [PATCH] Catch all exceptions there --- xbotlib.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xbotlib.py b/xbotlib.py index fc066fe..8a9d933 100644 --- a/xbotlib.py +++ b/xbotlib.py @@ -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}")