MIg*_*ele 6 perl catalyst template-toolkit
在我的舞台服务器中,我想激活调试,以便客户端可以在应用程序进入生产服务器之前找到自己的错误.
但我只想要消息的第一部分,而不是请求或会话数据.
例如:无法渲染模板"templates/home.tt2:file error - templates/inc/heater:not found".
该消息足以让我和我的客户看到"标题"调用拼写错误.
请求为客户提供了大量无关信息,但也有大量内部开发信息,应该一直隐藏!
问候
你想要的是重写 Catalyst 的dump_these
方法。这将返回要在 Catalyst 错误调试页面上显示的内容列表。
默认实现如下所示:
sub dump_these {
my $c = shift;
[ Request => $c->req ],
[ Response => $c->res ],
[ Stash => $c->stash ],
[ Config => $c->config ];
}
Run Code Online (Sandbox Code Playgroud)
但你可以让它更具限制性,例如
sub dump_these {
my $c = shift;
return [ Apology => "We're sorry that you encountered a problem" ],
[ Response => substr($c->res->body, 0, 512) ];
}
Run Code Online (Sandbox Code Playgroud)
您可以dump_these
在应用程序的主模块中定义 - 您所在的模块use Catalyst
。