I'm currently working on a project where it is critical that i can demonstrate how a program should behave in case an error occurs. In this instance, i want my program to except any errors that may be produced by a failed time.localtime()
call.
I understand that an error like this is highly unlikely to occur. Regardless, I would like to cover all possibilities. Therefore, what type of error would occur if my program was unable to get a response from time.time()
or time.localtime()
?
try:
time = time.time()
except #nameoferror:
print ("Unable to get current time")
What could i replace "#nameoferror"
with in order to output the message if the time function failed?