Exception passing

kyosohma at gmail.com kyosohma at gmail.com
Fri Mar 23 15:38:16 CET 2007

On Mar 23, 9:29 am, Thomas Dybdahl Ahle <lob... at gmail.com> wrote:
> Hi, I have a function, which looks like the following:
> connecting = False
> def func ():
>     global connecting
>     connecting = True
>     try:
>        # Do lot of network stuff
>     except Exception, e:
>         connecting = False
>         raise e
> This works quite good, but it is a hell to debug. Instead of getting a
> log message to the line which originally raised the exception.
> Is there anyway to reraise an exception, but preserve the log?

You could import traceback and use its functionality.

Lundh mentioned using sys.exc_info about an hour ago to another user.
See http://effbot.org/pyref/sys.exc_info.htm


More information about the Python-list mailing list