> So, my system template looks like:
> [%
>     TRY;
>         PROCESS "userTemplateNameWhichCanBeNotFound.tmpl";
>     CATCH file;
>         PROCESS "systemTemplateAlwaysFound.tmpl";
>     END;
> %]
> 
> So here, I try to process the template
> "userTemplateNameWhichCanBeNotFound.tmpl", and if there is not such tmpl,
> the "systemTemplateAlwaysFound.tmpl" is processed.
> 
> The previous template give me :
> file error - userTemplateNameWhichCanBeNotFound.tmpl: not found at
> /usr/lib/perl5/site_perl/5.6.0/Template/Context.pm line 499.
> undef error - [Thu Aug  9 13:05:18 2001]  31602 null ERR: file error -
> userTemplateNameWhichCanBeNotFound.tmpl: not found at
> /usr/lib/perl5/site_perl/5.6.0/Template/Context.pm line 499.
> seen on my browser and the same in the error log.FYI, I'm using perl 5.6.0 &
> TTK 2.04 & Apache 1.30.20 & modperl 1.25.What did I miss ?How can I REALLY
> catch the error ? Avoid the output to stderr ?Is it the correct way to do it
> ?Any help are welcome.kktos

It appears you have come across a subtle problem involving perl 5.6.0,
TT2 and CGI::carp.  TT2 exceptions (of any kind, including STOP) do not
work with CGI::Carp if you are using perl 5.6.0 and CGI.pm >= 2.67 (this
might be one of the issues in TT2's TODO).

The problem is that between version 2.66 and 2.67 of CGI.pm, CGI/Carp.pm
changed the definition of "ineval" from:

- BEGIN {
-   $] >= 5.005
-     ? eval q#sub ineval { defined $^S ? $^S : _longmess() =~ /eval [\{\']/m }#
-     : eval q#sub ineval { _longmess() =~ /eval [\{\']/m }#;
-   $@ and die;
- }

to:

+ sub ineval { _longmess() =~ /eval [\{\']/m }

Additionally, in perl 5.6.0 the stack trace (from Carp::Heavy::longmess_heavy)
used by CGI::Carp returns contains the string "require 0" instead of
"eval { }" when there is a die() inside an eval{}.

So the ineval() sub in CGI/Carp.pm doesn't think it is inside an
eval (since it no longer checks ^S) and the exception is not
dispatched correctly.

Here's an example:

    use Carp;
    eval { confess "oops" };
    print $@;

On perl 5.6.0 this prints:

    oops at test line 4
            require 0 called at q6 line 4

while on perl 5.6.1 this prints:

    oops at q6 line 4
            eval {...} called at q6 line 4

Your problem is solved in perl 5.6.1.  Or here's a patch to CGI/Carp.pm
that should fix the problem too:

    - sub ineval { _longmess() =~ /eval [\{\']/m }
    + sub ineval { defined $^S ? $^S : _longmess() =~ /eval [\{\']/m }

I did exchange emails with Lincoln about this issue, but he wasn't
inclined to change what is a pretty fragile part of the code.

Hmmm, I noticed Andy's fingerprints in Carp::Heavy; perhaps he can shed
some light on this?

Craig


Reply via email to