如何查找“模板进程失败:undef 错误”在 Perl 的模板工具包中?

发布于 2024-08-31 10:22:54 字数 1130 浏览 6 评论 0原文

我已将 Perl CGI 应用程序从一个网络主机移至另一个网络主机。一切都运行良好,除了 Template Tookit 出现以下错误:

“模板进程失败:undef 错误 - 这不应该发生在 /usr/lib/perl5/5.8.8/CGI/Carp.pm 第 314 行。”

这些模板在其他网络主机上运行良好。我在创建模板对象时设置了 DEBUG_ALL 标志,但它不提供有关错误的任何附加信息,只是加载调试输出。

我无法发布模板源,因为其中有很多客户特定的内容。

我写了一个简单的测试模板,效果很好。只是想知道是否有人以前见过这个错误,或者对找到解决方案的最快方法有任何想法。

编辑:这是加载和处理模板的代码片段。

my $vars     = {};
$vars->{page_url}         = $page_url;
$vars->{info}             = $info;
$vars->{is_valid}         = 0;
$vars->{invalid_input}    = 0;
$vars->{is_warnings}      = 0;
$vars->{is_invalid_price} = 0;
$vars->{output_from_proc} = $proc_output;
...

my $file = 'clientTemplate.html';

#create ref to hash
use Template::Constants qw( :debug );


my $template = Template->new(
{
    DEBUG => DEBUG_SERVICE | DEBUG_CONTEXT | DEBUG_PROVIDER | DEBUG_PLUGINS |   DEBUG_FILTERS | DEBUG_PARSER | DEBUG_DIRS,
    EVAL_PERL    => 1,
    INCLUDE_PATH => [
        '/home/perlstuff/templates',
    ],
}
);

$template->process( $file, $vars )
  || die "Template process failed: ", $template->error(), "\n";

I've moved a Perl CGI app from one web host to another. Everything's running fine except for Template Tookit which is giving the following error:

"Template process failed: undef error - This shouldn't happen at /usr/lib/perl5/5.8.8/CGI/Carp.pm line 314."

The templates are working fine on the other web host. I've set the DEBUG_ALL flag when creating the template object, but it doesn't provide any additional info about errors just loads of debug output.

I can't post the template source as there's lots of client specific stuff in it.

I've written a simple test template and that works okay. Just wondering if anyone had seen this error before or has any ideas on the quickest way to find a fix for it.

EDIT: Here's a snippet of the code that loads and processes the template.

my $vars     = {};
$vars->{page_url}         = $page_url;
$vars->{info}             = $info;
$vars->{is_valid}         = 0;
$vars->{invalid_input}    = 0;
$vars->{is_warnings}      = 0;
$vars->{is_invalid_price} = 0;
$vars->{output_from_proc} = $proc_output;
...

my $file = 'clientTemplate.html';

#create ref to hash
use Template::Constants qw( :debug );


my $template = Template->new(
{
    DEBUG => DEBUG_SERVICE | DEBUG_CONTEXT | DEBUG_PROVIDER | DEBUG_PLUGINS |   DEBUG_FILTERS | DEBUG_PARSER | DEBUG_DIRS,
    EVAL_PERL    => 1,
    INCLUDE_PATH => [
        '/home/perlstuff/templates',
    ],
}
);

$template->process( $file, $vars )
  || die "Template process failed: ", $template->error(), "\n";

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥抱我好吗 2024-09-07 10:22:54

您可以尝试使用 Devel::SimpleTrace 来获取代码位置的堆栈跟踪是当它遇到错误时。也许这会让您更好地了解正在发生的事情。

You might try using Devel::SimpleTrace to get a stack trace of where the code is when it runs into the error. Perhaps that will give you a little better clue as to what is happening.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文