From 3cc86f0dbe709d6499155faeda8ea8b1ce10a4d1 Mon Sep 17 00:00:00 2001 From: Joe Kaufeld Date: Mon, 16 Sep 2024 18:05:10 -0400 Subject: [PATCH] :bug: fix crash loop if template rendering fails --- spiderweb/main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spiderweb/main.py b/spiderweb/main.py index 4817f0c..edf9f79 100644 --- a/spiderweb/main.py +++ b/spiderweb/main.py @@ -187,7 +187,14 @@ class SpiderwebRouter(LocalServerMixin, MiddlewareMixin, RoutesMixin, FernetMixi start_response(status, headers) - rendered_output = resp.render() + try: + rendered_output = resp.render() + except Exception as e: + self.log.error("Fatal error!") + self.log.error(e) + self.log.error(traceback.format_exc()) + return [f"Internal Server Error: {e}".encode(DEFAULT_ENCODING)] + if not isinstance(rendered_output, list): rendered_output = [rendered_output] encoded_resp = [