Re: [Templates] how to see error messages
[prev]
[thread]
[next]
[Date index for 2005/04/11]
>>>>> "Dave" == Dave Howorth <dhoworth@xxxxxxx.xxx.xx.xx> writes:
Dave> A while ago I posted a question about how to retrieve diagnostic
Dave> information but didn't get any replies. So I'd like to rephrase my
Dave> question to see if anybody can help.
Dave> In my template, I say something like:
Dave> [% USE c = Class('MyClass') ;
Dave> v = c.some_method(args) %]
Dave> My problem is that some_method is dying but I don't get any diagnostic
Dave> output. It seems as though TT just swallows the message. I've tried
Dave> Template::Provider->new({DEBUG => 'all'});
Dave> but that still doesn't show the die message from my method.
Dave> Can anybody tell me how to retrieve this message?
Either use template-level TRY blocks:
TRY;
USE c = Class('MyClass');
v = c.some_method(args);
CATCH;
FILTER stderr;
"Caught ${error.type} with ${error.info}\n";
END;
END;
or be sure you're looking at the errors coming out of ->process:
eval {
...
$tt->process(...)
or die $tt->error;
...
};
if ($@) {
if (UNIVERSAL::isa($@, "Template::Exception")) {
## error came from Template or below
if ($@->type eq "undef") { # yes, the letters u n d e f!
die $@->info; # the error from below Template (perl code plugins)
} else {
## the error came from a Template step, do what you want
die "$@"; # stringifies the Template error
}
} else {
## the error came from above Template (something else in the eval)
die $@; # throw it again
}
}
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxx.xxx> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
 |
Re: [Templates] how to see error messages
merlyn (Randal L. Schwartz) 14:45 on 11 Apr 2005
|