[Tutor] Re: catching any exception?
alan.gauld@bt.com
alan.gauld@bt.com
Sun Nov 17 11:35:02 2002
> But I've noticed that the code only works for any of the "standard"
> exceptions. If I define my own exception, which is what
> DCOracle does, and raise that, it's not caught:
>
> >>> myException = 'my sample exception'
String exceptions have been deprecated in Python since(I think) v2...
But since many utilities etc use them...
> See, "myException" was not caught. How can I catch all exceptions,
> including the ones that DCOracle defines?
try:
# foo
except:
# now use traceback module to figure out what exactly got caught!
a plain "except:" will catch any kind of exception.
Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld