From fd8df68debaf0ae26f5e4e7d2283369992e9b981 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 27 Oct 2020 12:59:19 +0000 Subject: [PATCH] add exception handler --- fet2020/posts/models.py | 7 ++++++- fet2020/posts/views.py | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fet2020/posts/models.py b/fet2020/posts/models.py index 3cd4e7cd..25b3a0c2 100644 --- a/fet2020/posts/models.py +++ b/fet2020/posts/models.py @@ -102,7 +102,12 @@ class Post(models.Model): if not self.agenda_key: return None - html = getPadHTML(self.agenda_key) + try: + html = getPadHTML(self.agenda_key) + except Exception as e: + logger.error("Can't get the agenda html from agenda key '{}'. Error: {}".format(self.agenda_key, e)) + html = None + return html @agenda_html.setter diff --git a/fet2020/posts/views.py b/fet2020/posts/views.py index ac40ebb5..690c414f 100644 --- a/fet2020/posts/views.py +++ b/fet2020/posts/views.py @@ -74,10 +74,18 @@ def show(request, id=None): ep_protocol_link = "#" if p.has_agenda and p.agenda_key: - ep_agenda_link = get_pad_link(p.agenda_key) + try: + ep_agenda_link = get_pad_link(p.agenda_key) + except Exception as e: + logger.error("Can't get the agenda link from '{}'. Error: {}".format(p.agenda_key, e)) + ep_agenda_link = "#" if p.has_protocol and p.protocol_key: - ep_protocol_link = get_pad_link(p.protocol_key) + try: + ep_protocol_link = get_pad_link(p.protocol_key) + except Exception as e: + logger.error("Can't get the protocol link from '{}'. Error: {}".format(p.protocol_key, e)) + ep_protocol_link = "#" context = { "post": p,