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:
parent
d09267cd6c
commit
7d208780aa
1 changed files with 6 additions and 4 deletions
|
@ -23,14 +23,16 @@ def article(article_url):
|
||||||
for paragraph in page.content:
|
for paragraph in page.content:
|
||||||
for child in paragraph.children:
|
for child in paragraph.children:
|
||||||
if child.__class__.__name__ == "GithubGist":
|
if child.__class__.__name__ == "GithubGist":
|
||||||
gist_id = child.id
|
try:
|
||||||
gist = GithubClient.get_gist(gist_id)
|
gist = GithubClient.get_gist(child.id)
|
||||||
child.content = gist
|
child.content = gist
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error fetching gist: {str(e)}")
|
||||||
|
|
||||||
return render_template("article.html", page=page)
|
return render_template("article.html", page=page)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(e, NotFound):
|
if isinstance(e, NotFound):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
print(f"Error fetching article: {str(e)}")
|
print(f"Error fetching article: {str(e)}")
|
||||||
abort(500)
|
abort(500)
|
||||||
|
|
Loading…
Reference in a new issue