我们有一些代码可以捕获异常,记录消息,然后调用Carp::longmess
以获取堆栈跟踪。
因此,我们正在做的简化视图是:
eval { <some SOAP::Lite stuff> };
if( my $err = $@ )
{
logwrite( "Caught Error: $err" );
}
logwrite函数本质上是:
sub logwrite($)
{
my $msg = $_[0];
my($pkg,$fil,$lin)=caller;
my $timestamp = POSIX::strftime(...);
print STDERR "$timestamp $fil/$lin $msg\n";
print STDERR "$timestamp $fil/$lin Stack trace:\n" . Carp::longmess . "\n";
}
但在我看到的日志中:
20111030 Module.pm/42 Caught Error: at line
Use of uninitialized value in caller at /usr/lib/perl5/5.8.8/Carp/Heavy.pm line 22.
Use of uninitialized value in string eq at /usr/lib/perl5/5.8.8/Carp/Heavy.pm line 91.
Use of uninitialized value in numeric lt (<) at /usr/lib/perl5/5.8.8/Carp/Heavy.pm line 200.
Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/5.8.8/Carp/Heavy.pm line 55.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/5.8.8/Carp/Heavy.pm line 55.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/5.8.8/Carp/Heavy.pm line 142.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/5.8.8/Carp/Heavy.pm line 142.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/5.8.8/Carp/Heavy.pm line 142.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/5.8.8/Carp/Heavy.pm line 142.
...
来自模块的一系列警告会Carp/Heavy.pm
无限地重复一遍又一遍,炸毁日志。所以我们最终将其杀死。这些警告看起来像是由对 的调用触发的Carp::longmess
。这里的另一个有趣的事情是$@
变量似乎只是at
。它是at
由模具添加的,但没有实际的错误消息或行号。
有没有人见过这个或者知道这个Carp
包裹是怎么回事?这种情况很少见,但在过去一个月左右发生了几次,我们每天都有数百个这样的工作在运行。