Re: exceptions again?

Ron Forrester (rjf@aurora.pcg.com)
Tue, 31 Jan 1995 10:51:23 -0700

On Tue, 31 Jan 1995 00:20:01 +0100, Guido.van.Rossum@cwi.nl wrote:

> try:
> ...
> except IOError, msg:
> print "I/O Error:", msg
>
> Otherwise, you can use the type() and len() functions to detect what
> kind of error data you have, e.g.
>
> if type(msg) == type(()): # It's a tuple
> if len(msg) == 2:
> left, right = msg
> print left, ":", right
> elif len(msg) == 4:
> errortype, errorcode, errormsg, messageobject = msg
> if errorcode == 404:
> ...
> etc.
> else:
> print msg # Tuple of other size
> else:
> print msg # Not a tuple

Thanks Guido! I appreciate the help (and patience with my basic questions)...

rjf

-- 
| "I don't like being bluffed -- makes me doubt     |    rjf@aurora.pcg.com |
| my perception of reality..."                      |            71722,3175 |
|                      Chris in the morning on KBHR |                       |
+---------------------------------------------------+-----------------------+