Re: [Templates] Unexpected errors with COMPILE_DIR and TOLERANT

[prev] [thread] [next] [Date index for 2004/12/22]

From: Simon Flack
Subject: Re: [Templates] Unexpected errors with COMPILE_DIR and TOLERANT
Date: 19:50 on 22 Dec 2004

Tom Insam wrote:
> 
> On Dec 22, 2004, at 10:40, Andy Wardley wrote:
> 
>> You're ignoring any error that is returned.  That should be:
>>
>>       $tt->process(...)
>>            || die $tt->error();
> 
> 
> I don't suppose I can convince you to throw $tt->error all the time, can 
> I? If I want to do something clever, I'll eval the process step and 
> catch the error. If not, I'd prefer the default to be safe...

You can try, but you'll have to try harder :)

Particularlyin a small test script, I don't see the benefit(s) of:

	eval {$tt->process(...) || die $tt->error};
	if ($@) {
		# do something with the exception
	}

over:
	unless ($tt->process(...)) {
		# do something with $tt->error
	}

$tt->process /could/ throw a Template::Exception on failure, but it 
doesn't. The idiom, '$tt->process() || die $tt->error' is a useful 
mantra because it reminds people to check for errors. But that's not the 
only way to do it.

The same goes for system calls like open(), system() etc. I don't have a 
particular preference and use whatever feels most natural in the context.

Simon

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

(message missing)

Re: [Templates] Unexpected errors with COMPILE_DIR and TOLERANT
Simon Flack 19:50 on 22 Dec 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52