Print Error Type when I catch it

Jimbo nilly16 at yahoo.com
Thu Apr 22 19:50:30 EDT 2010


Hello

I have a relatively simple question. I want to use a try except in a
function & when an error occurs I want to print the error type name(eg
IOError, OSError etc) do you know how I can do this without specifying
all possible errors, eg having to do this "except (IOError, OSError,
IndexError, ....):"

try:

    ... some code

except:
     # Here I want to print type of error that occured
     print errorType

The reason I want to do this is because one of my complex programs is
crashing BUT no python error message is comming up in red when I run
it, so I cant figure out what error occured? So I think its time I
learnt to print out my own errors & their types



More information about the Python-list mailing list