Handle ValueError.
This commit is contained in:
parent
d1c98cd9c7
commit
be5ff7177c
1
.gitignore
vendored
1
.gitignore
vendored
@ -112,3 +112,4 @@ dmypy.json
|
|||||||
|
|
||||||
# database files (may contain sensitive student info)
|
# database files (may contain sensitive student info)
|
||||||
*.db
|
*.db
|
||||||
|
.vscode
|
||||||
|
2
TODO.md
2
TODO.md
@ -2,7 +2,7 @@ To-Do List
|
|||||||
==========
|
==========
|
||||||
|
|
||||||
## v0.2
|
## v0.2
|
||||||
- [ ] Error handling (when entering invalid data types)
|
- [x] Error handling (when entering invalid data types)
|
||||||
- [ ] Make database contain data for all classes
|
- [ ] Make database contain data for all classes
|
||||||
- [ ] Flexible mandatory subjects
|
- [ ] Flexible mandatory subjects
|
||||||
|
|
||||||
|
@ -102,23 +102,26 @@ def main():
|
|||||||
|
|
||||||
y = "y"
|
y = "y"
|
||||||
while y == "y":
|
while y == "y":
|
||||||
id = int(input("Please input the student ID number: "))
|
try:
|
||||||
|
id = int(input("Please input the student ID number: "))
|
||||||
|
|
||||||
if check_id(conn, id):
|
if check_id(conn, id):
|
||||||
day = get_lower_weekday()
|
day = get_lower_weekday()
|
||||||
raw_time = select_final_time(conn, day, id)
|
raw_time = select_final_time(conn, day, id)
|
||||||
# if raw_time is None, student has no lessons today
|
# if raw_time is None, student has no lessons today
|
||||||
if raw_time != None:
|
if raw_time != None:
|
||||||
final_time = parse_time_string(raw_time)
|
final_time = parse_time_string(raw_time)
|
||||||
current_time = parse_time_string(time.strftime("%H:%M"))
|
current_time = parse_time_string(time.strftime("%H:%M"))
|
||||||
if current_time > final_time:
|
if current_time > final_time:
|
||||||
|
print("Clear to leave.")
|
||||||
|
else:
|
||||||
|
print("Student does not have clearance.")
|
||||||
|
elif raw_time == None:
|
||||||
print("Clear to leave.")
|
print("Clear to leave.")
|
||||||
else:
|
else:
|
||||||
print("Student does not have clearance.")
|
print("Student does not exist in the database. Please try again.")
|
||||||
elif raw_time == None:
|
except ValueError:
|
||||||
print("Clear to leave.")
|
print("That was not an integer, please try again.")
|
||||||
else:
|
|
||||||
print("Student does not exist in the database. Please try again.")
|
|
||||||
|
|
||||||
y = input("Press y key followed by enter to run again.")
|
y = input("Press y key followed by enter to run again.")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user