Newbie: Capture traceback message to string?
Gary Herron
gherron at islandtraining.com
Tue Jan 16 21:19:34 EST 2007
Sean Schertell wrote:
> Hello!
>
> I'm new to Python and this is my first post to the list.
>
> I'm trying to simply capture exception text to a few strings which
> can be passed to a PSP page to display a pretty error message. The
> problem is that I just can't seem to figure out how to get the basic
> components of the traceback message into strings. Here's what I want
> to do:
>
The traceback module provides a wealth of ways to get at the exception
information, formated and usable in various ways.
See: http://docs.python.org/lib/module-traceback.html
Gary Herron
> ---------------------
> try:
> bad_math = 1/0
> except:
> info = sys.exc_info()
> main_error_str = # ???
> full_traceback_str = # ???
> tmpl = psp.PSP(req, filename='error.html')
> tmpl.run({'main_error_str': main_error_str,
> 'full_traceback_str':full_traceback_str})
>
> return apache.OK
> ---------------------
>
> ...So then my PSP page receives the errors as variables containing
> strings.
>
> I've been googling and experimenting for more hours than I care to
> admit. A little help please?
>
> Thanks!
>
> Sean
>
>
>
More information about the Python-list
mailing list