aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--on_this_day.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/on_this_day.py b/on_this_day.py
index 5813f18..ea9e1e5 100644
--- a/on_this_day.py
+++ b/on_this_day.py
@@ -5,8 +5,20 @@ from bs4 import BeautifulSoup
from config import config
+def check_error(func, name):
+ try:
+ return func()
+ except:
+ return "Error getting %s" % name
+
def get_on_this_day():
- return "<h1>On this day</h1><ul><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>%s" % (get_old_news(), get_peanuts(), get_calvin_and_hobbes(), get_today_wikipedia(), get_today_wikiquote())
+ old_news = check_error(get_old_news, "old news")
+ peanuts = check_error(get_peanuts, "peanuts")
+ calvin_and_hobbes = check_error(get_calvin_and_hobbes, "calvin and hobbes")
+ wikipedia = check_error(get_today_wikipedia, "wikipedia")
+ wikiquote = check_error(get_today_wikiquote, "wikiquote")
+
+ return "<h1>On this day</h1><ul><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>%s" % (old_news, peanuts, calvin_and_hobbes, wikipedia, wikiquote)
def get_old_news():
print("getting old news")