The first exception handler I coded was this:
try:
f = urllib.urlopen(url)
except IOError, (error, msg):
print error + ": " + msg
return
This worked great when the exception type thrown was a socket error (i.e.
('socket error', 'host not found')) or any one with only two members in the
tuple.
However, if I specify an unknown host, I get this message:
('http error', 404, 'Not Found', <Message instance at 3222ec>)
and an error saying that the tuple unpacked to the wrong size -- this makes
sense.
My question is, how do I code the except such that I can handle and correctly
identify each type of error appropriately?
Thanks!
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 | | +---------------------------------------------------+-----------------------+