exception handling
Doug Stanfield
DOUGS at oceanic.com
Mon May 8 19:31:49 EDT 2000
import traceback
try:
# something that will raise an exception
except:
traceback.print_exc() # Print the exception
Is that what you wanted?
-Doug-
> -----Original Message-----
> From: Jp Calderone [mailto:exarkun at flashmail.com]
> Sent: Monday, May 08, 2000 12:37 PM
> To: python-list at python.org
> Subject: exception handling
>
>
>
> Is there any way to catch *all* exceptions raised in a
> try/except block *and* get a reference to the exception
> that was raised? I basically just need to print out the
> exception, as the interpreter does when an unhandled
> exception is raised, but with extra formatting and such.
> I've tried the sys.exc_info() function, but it always
> seems to return (None, None, None) - even when it is
> being called in an except block, where it obviously
> *should* have info on an exception.
>
> Thanks in advance,
> Jp
>
>
>
> --
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GCS dpu>-- s+: a--- C++++ UL++++ P+ L+++ E---- W++ N++ o+ K- w---
> O-- M- V- PS+++ PE- Y+ PGP t+ 5+ X++ R+ tv+ b++ DI++ D---
> G e* h! !r y--
> ------END GEEK CODE BLOCK------
> --
> 6:34pm up 5 days, 23:02, 6 users, load average: 0.07, 0.09, 0.03
> --
> http://www.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list