From 7d208780aa64d1d844a0d612c2d02556019e62c4 Mon Sep 17 00:00:00 2001 From: Kumi Date: Thu, 19 Sep 2024 18:59:03 +0200 Subject: [PATCH] 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. --- src/small/views/article.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/small/views/article.py b/src/small/views/article.py index ce2484f..93d90b2 100644 --- a/src/small/views/article.py +++ b/src/small/views/article.py @@ -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)