[ZPT] Line numbers in errors

Shane Hathaway shane@zope.com
Thu, 12 Sep 2002 11:06:40 -0400


Richard Jones wrote:
> I'd like to include the line number of an error when there's a run-time error 
> generated from an expression. I've had a poke through the source, but 
> couldn't see anything obvious. Is there any way of getting that information 
> into the expressions so I can pull it out in my exception handler?

If you're using the Zope CVS trunk, look at the ExceptionFormatter class 
in zExceptions.  It searches the stack frame objects for 
__traceback_supplement__ variables, and when it finds them, it inserts 
the information provided by the supplement into the traceback.  The 
PageTemplate code uses this method to show template filenames and line 
numbers.

Shane