given the trace error log, I don't always know how to catch a specific exception.
my question in general is how to determine which "except" clause needs to be written to handle a specific exception.
example 1:
File "c:\programs\python\lib\httplib.py", line 683, in connect
raise socket.error, msg
error: (10065, 'No route to host')
Example 2:
return codecs.charmap_encode(input,errors,encoding_table)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position(...)
The capture of the second example is obvious:
try:
...
except UnicodeDecodeError:
...
How will I definitely catch the first mistake?
source
share