List Info

Thread: redirect the fatal error to browser




redirect the fatal error to browser
user name
2006-05-25 06:45:31
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?

-- 
perl -e 'print
unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\
"\``
")'

_______________________________________________
templates mailing list
templatestemplate-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates
redirect the fatal error to browser
user name
2006-05-25 10:50:35
* Ken Perl <kenperl at gmail.com> [2006/05/25 14:45]:
> 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?

Errors are not handled by TT, you need to do that in your
front end.
tpage does that for you, which is why you see the error on
the command
line.  In your CGI script, you need to do something like:

  $tt->process(...) || die $tt->error;

If you are using CGI::Carp, the die will get caught and
displayed like
you want.

(darren)

-- 
The Earth quakes and the heavens rattle; the beasts of
nature flock
together and the nations of men flock apart; volcanoes usher
up heat
while elsewhere water becomes ice and melts; and then on
other days it
just rains.
    -- Principia Discordia
redirect the fatal error to browser
user name
2006-05-25 20:19:41
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Darren Chamberlain wrote:
> * Ken Perl <kenperl at gmail.com> [2006/05/25
14:45]:
>> 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?
> 
> Errors are not handled by TT, you need to do that in
your front end.
> tpage does that for you, which is why you see the error
on the command
> line.  In your CGI script, you need to do something
like:
> 
>   $tt->process(...) || die $tt->error;
> 
> If you are using CGI::Carp, the die will get caught and
displayed like
> you want.

Wow, you're right!  What I said was just flat wrong.  I
just took
another look at my code, and it does indeed call die:

my $body = '';
unless( $tt->process( 'uploader.html', $tt_vars,
\$body ) )
{
	die "Error with Template: ", $tt->error;
}

In my defense, I must say that I've been using this piece
of code,
unmodified, for over a year in every TT script that I've
written so
far--so you can understand how I took it for granted.

Sorry for the misinformation!
- --

C. Chad Wallace, B.Sc.
The Lodging Company
http://skihills.com/
OpenPGP Public Key ID: 0x262208A0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


iD8DBQFEdhFcKeSNHCYiCKARAlH5AJ9rnKKhINh02gG4B7EbTTgSN851iwCg
x9z4
U+9S0bdeDTnFtlp7h3lWi5c=
=qZz4
-----END PGP SIGNATURE-----

_______________________________________________
templates mailing list
templatestemplate-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates
redirect the fatal error to browser
user name
2006-05-25 16:27:21
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

_______________________________________________
templates mailing list
templatestemplate-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates
redirect the fatal error to browser
user name
2006-05-29 01:39:48
I call it like this,
$tt->process( $input, $vars, \$output ) || die
$tt->error();
but when there is a syntax error in search.xhtml template
file like my
previous post, the error can't be caught, could you help?

On 5/26/06, C. Chad Wallace <cwallacethelodgingco.com> wrote:
> 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
>
> _______________________________________________
> templates mailing list
> templatestemplate-toolkit.org
> http://lists.template-toolkit.org/mailman/listinfo/t
emplates
>


-- 
perl -e 'print
unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\
"\``
")'

_______________________________________________
templates mailing list
templatestemplate-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )