[Tutor] Socket Error Handling Syntax
Andreas Perstinger
andipersti at gmail.com
Tue May 28 21:27:51 CEST 2013
On 28.05.2013 19:25, sparkle Plenty wrote:
> I need to catch and handle 10057 exceptions when they occur and keep
> running. I know 10057 is a WinError, which is a subset of OSError, I
> just can't find the right syntax for it. I would appreciate some
> help on this one.
I have neither Windows nor Python3.3 to test but according to the docs,
"winerror" is an attribute of the OSError exception (
http://docs.python.org/3/library/exceptions.html?highlight=oserror#OSError
). Thus something like
try:
# some code
except OSError as e:
if e.winerror == 10057:
# do error handling
else:
raise # re-raise any other error
should work.
Bye, Andreas
More information about the Tutor
mailing list