浏览代码

better invalid date error message
This is more likely to occur when getting the constraint columns in the wrong
order than any other kind of user or programming error, so a vanilla error
message is more useful than a stack trace here.

Justin Tracey 4 年之前
父节点
当前提交
ceb37164ec
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      vice-speaker-rotator.py

+ 5 - 1
vice-speaker-rotator.py

@@ -13,7 +13,11 @@ https://cs.uwaterloo.ca/twiki/view/CrySP/UpcomingEvents
 """
 
 def str_to_date(string_date):
-    return date(*[int(s) for s in string_date.split('-')])
+    try:
+        return date(*[int(s) for s in string_date.split('-')])
+    except:
+        print("invalid date: " + string_date)
+        sys.exit()
 
 class CryspCalendar:
     """Representation of a CrySP weekly meeting schedule for a term"""