Explorar o código

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 %!s(int64=4) %!d(string=hai) anos
pai
achega
ceb37164ec
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  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"""