[FRPythoneers] Printing a traceback

Ken Kinder kkinder at tridog.com
Mon Aug 27 10:45:42 MDT 2001


Right, but then I can't email myself the exception because it's
unhandled. FYI, this was suggested by someone else and works wonders:

	import traceback, sys
	try:
		...
	except:
		typ, val, tb = sys.exc_info()
		error_text = traceback.format_exception(typ, val, tb).join('')

Works great. Then I email myself error_text -- CGI glory.

Thanks for all your input.

PC Drew wrote:
> 
> you could create a new StringIO object and store that object in
> sys.__stderr__
> 
> ----- Original Message -----
> From: "Ken Kinder" <kkinder at tridog.com>
> To: "Front Range Pythoneers" <frpythoneers at lists.community.tummy.com>
> Sent: Monday, August 27, 2001 10:27 AM
> Subject: [FRPythoneers] Printing a traceback
> 
> > If I have a statement like:
> >
> > try:
> > (bad code)
> > except:
> > typ, val, tb = sys.exc_info()
> > ....
> >
> > How do I put the traceback-like text in a string variable? That is, I
> > want the text that would otherwise be printed to sys.stderr if I hadn't
> > have caught the error.
> >
> > --
> > Ken Kinder - Engineer
> > Par Avance, Inc. / Tridog Interactive, Inc.
> > _______________________________________________
> > This message sent by the FRPythoneers mailing list.
> > Unsubscribe: echo unsubscribe |
> FRPythoneers-request at lists.community.tummy.com
> > URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers
> >
> 
> _______________________________________________
> This message sent by the FRPythoneers mailing list.
> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers

-- 
Ken Kinder - Engineer
Par Avance, Inc. / Tridog Interactive, Inc.



More information about the FRPythoneers mailing list