fix(article): handle gist fetch errors gracefully

Added try-except block around gist fetch to handle potential
errors more gracefully by printing error messages instead of
failing silently. This improves debugging and user experience
when fetching GitHub gists in articles.
This commit is contained in:
Kumi 2024-09-19 18:59:03 +02:00
parent d09267cd6c
commit 7d208780aa
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -23,14 +23,16 @@ def article(article_url):
for paragraph in page.content:
for child in paragraph.children:
if child.__class__.__name__ == "GithubGist":
gist_id = child.id
gist = GithubClient.get_gist(gist_id)
child.content = gist
try:
gist = GithubClient.get_gist(child.id)
child.content = gist
except Exception as e:
print(f"Error fetching gist: {str(e)}")
return render_template("article.html", page=page)
except Exception as e:
if isinstance(e, NotFound):
raise
print(f"Error fetching article: {str(e)}")
abort(500)