On 05Sep2017 10:50, Antoon Pardon <antoon.par...@vub.be> wrote:
Python 2.6.4 on a solaris box.

I have a program in which all kind of excptions can be thrown and caugth.
The main program is something like below:

try:
   do_stuff
except Exception:
   log unexpected trouble

Now I found the following in the logs: [Errno 131] Connection reset by peer

This is a problem I would like to catch earlier however I have no idea what
exception I would have to catch in order to treat this case.

Almost anything which says "Errno ..." is almost always an OSError (or an IOError as I found the other day). I try to be quite picky about these. So for example:

 try:
   fp = open(filename)
 except OSError as e:
   if e.errno == errno.ENOENT:
     # file missing
     ... act as if the file were empty ...
   else:
     # other badness - let the exception escape
     raise

Cheers,
Cameron Simpson <c...@cskk.id.au> (formerly c...@zip.com.au)
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to