I understand the basic syntax try: except: finally:for handling pythons errors. I do not understand how to find the correct error names to make readable code.
For instance:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.settimeout(60)
char = s.recv(1)
except socket.timeout:
pass
therefore, if the socket causes a timeout, the error is caught. How about if I look for a connection refused. I know the error number is 10061. Where in the documentation I am looking to find the value of a full name, such as a timeout. Would a similar place look for other python modules? I know this is a newbie question, but I have been processing my code for some time, not knowing where to look for error descriptions and names.
EDIT:
Thanks for all your answers.
will be
except socket.error, exception:
if exception.errno == ETIMEDOUT:
pass
achieve the same result as
except socket.timeout:
pass