sys.excepthook, getting traceback values

J

Josh Close

When sys.excepthook is called, type, value and traceback are passed
into it. How do I get the values of traceback?

I've tried printing it, but I get the memory location. I'm gussing
there are some methods to use on it.
From what I can tell the traceback that's passed in works differently
from the module traceback.

I just need to get the traceback to log it. I can use type and value,
but that doesn't print what line the error occurred.

-Josh
 
L

Larry Bates

Here is what I use:

import traceback
#
# Get traceback lines
#
tblines=traceback.format_exception(type, value, tb)

Basically this is what prints in an uncaught exception.
You can then print, write to file, etc.

HTH,
Larry Bates
Syscon, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top