[Templates] redirect the fatal error to browser

C. Chad Wallace cwallace@thelodgingco.com
Thu, 25 May 2006 09:27:21 -0700


Ken Perl wrote:
> when some syntax errors in the template html file, I can't see what's
> happened. If I go to the command line the to re-create the problem
> then I can see the error like this,
> 
> file error - parse error - search.xhtml line 71: unexpected end of
> directive
>  [% FOREACH d = [ '1','2','three' %]
> so I know a ']' is missed, for other errors I may use CGI::Carp
> qw(fatalsToBrowser); to catch the error and see it from the browser.
> My question is how can I catch template error like above to browser?

With all my scripts and templates, the errors do come to the browser
(via CGI::Carp).  It could be that you have your Template calls
inside an eval block.  Then when Template dies from errors, your
script will catch the error and set $@ instead of dying out to
CGI::Carp.

We'd have a better idea of what's going on if you could post the
code you use to load and run your templates.

-- 

C. Chad Wallace, B.Sc.
The Lodging Company
http://skihills.com/
OpenPGP Public Key ID: 0x262208A0