Subject: | Using default warning_handler causes error "Can't locate object method "error_handler" via package "Formatting..."" |
Date: | Thu, 12 Mar 2009 15:56:01 -0400 |
To: | bug-Text-xSV [...] rt.cpan.org |
From: | "Carey M. Drake" <carey [...] frieduck.com> |
The default warning_handler:
warning_handler => sub {
my $self = shift;
eval {
$self->error_handler(@_);
};
warn $@ if $@;
},
is not called in an object context (i.e. $self is not passed as first
parameter) by the Text::xSV::warning_handler method. So, when it's
called, it shifts the actual warning message into $self, and then
attempts to call error_handler with that warning message as the package
name. This will result in an error message like:
Can't locate object method "error_handler" via package "Formatting 13
fields at row 20253, expected 14" (perhaps you for got to load
"Formatting 13 fields at row 20253, expected 14"?) at
C:/Perl/site/lib/Text/xSV.pm line 342.
Removing the "my $self = shift;" line in the anon sub will result in the
sub being created as a closure containing the $self created in the "new"
sub scope. This fixes the error, and does what the author appeared to
intend.
Regards,
Carey
Message body not shown because it is not plain text.