[Tutor] Socket Error Handling Syntax

Dave Angel davea at davea.name
Tue May 28 21:49:06 CEST 2013


On 05/28/2013 03:37 PM, sparkle Plenty wrote:
> If I use an if statement, I cannot use continue after I do my error
> handling,

The presence of an if statement cannot affect whether or not a continue 
can work.  If you give a concrete code example, somebody will be able to 
identify the confusion.

And while you're at it, instead of saying "this failed" why not actually 
show us the traceback?  Big difference between a name error and a type 
problem.

> so I am really trying to use the except errorname: instead of an
> if statement.  Therefore, I have to find the correct error name to identify
> the 10057 condition to the interpreter, but thanks anyway, Andreas.
>

except clauses do not work on "error names" they work on exception 
types.  I don't use Windows, but I doubt if there's a separate exception 
type for 10057.

Incidentally, if you ever do get one of those except clauses to fire, 
you're going to want an exception object. Something like:

    except OSError as theError:

Then you can check the error code for anything you like.


-- 
DaveA


More information about the Tutor mailing list