Catch unknown exception

Roy Smith roy at panix.com
Fri Oct 29 09:21:50 EDT 2004


In article <pan.2004.10.29.09.36.57.887028 at it-snedkeren.BLACK_HOLE.dk>,
 Thomas Lindgaard <thomas at it-snedkeren.BLACK_HOLE.dk> wrote:

> How do I do that? Is there a way to check which exception is being caught
> - something along the lines of:
> 
>   try:
>     # something throws an exception
>   except:
>     printHumanReadableDescriptionOfException()

You want something like:

import sys
try:
    raise IndexError
except:
    print sys.exc_info()



More information about the Python-list mailing list