Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
ceb37164ec
1 zmenil súbory, kde vykonal 5 pridanie a 1 odobranie
  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"""