Re: [Templates] how to see error messages
[prev]
[thread]
[next]
[Date index for 2005/04/13]
Andy Wardley wrote:
> Dave Howorth wrote:
>
>>my $tt = Template->new();
>
> Try this:
> my $tt = Template->new( DEBUG => 'undef' ); # yes, the string "u n d e f"
Hi Andy,
Thanks for your reply. The problem with this suggestion is that I also
have lots of templates that say things like:
[% IF fred ; do_something ; END %]
This seems like normal TT code to me, but it breaks with that debugging
flag. I don't really want to rewrite all my templates just to make
debugging one class of error easier.
>>test.tt
>>-------
>>[% USE Test = Class('MyTest') ;
>> Test.method() ;
>> 'success'
>>%]
>
>
> With the DEBUG flag set as shown, undefined values are thrown as exceptions:
>
> "undef error - method is undefined"
>
> TT treats all data types as equal (more or less). foo.bar returns
> the 'bar' part of 'foo', or undef if it doesn't exist (including a
> 'bar' method missing from a 'foo' object). And by default, TT ignores
> any undefined values unless you set the DEBUG => undef flag.
>
> I admit it's not entirely obvious or helpful in cases like this, but that's
> the way it is I'm afraid. It may get better in v3...
I could see the rationale if it was 'method' that was missing. But here
the 'bar' part of 'foo' does exist and it runs. Then it throws an
exception and normally TT will catch that exception and report it. But
here it apparently singles out a particular type of exception and
chooses to leave me in ignorance.
Still, at least I know where I stand now.
I'm wondering if I could patch it. Is there extra code somewhere that
detects this special case? Or is there (IMHO) not quite enough code
checking the results wherever the method is invoked?
Thanks, Dave
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates