Skip Menu |

This queue is for tickets about the Template-Plugin-Class CPAN distribution.

Report information
The Basics
Id: 11538
Status: resolved
Priority: 0/
Queue: Template-Plugin-Class

People
Owner: Nobody in particular
Requestors: dhoworth [...] mrc-lmb.cam.ac.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.12
Fixed in: (no value)



Subject: misdiagnosis of 'missing' class
My application fell over a week ago. I think I've tracked the problem down to a buglet in your excellent Template::Plugin::Class (v0.12). It tries to load the class I asked to use and decides whether it found an error with an RE: 12 # stolen from base.pm 13 eval "require $arg"; 14 # Only ignore "Can't locate" errors from our eval require. 15 # Other fatal errors (syntax etc) must be reported. 16 die if $@ && $@ !~ /^Can't locate .*? at \(eval /; My immediate problem is that I'd just included something in my application that included a 'use diagnostics' statement. Now this reformats normal error messgaes (I posted the full error message to the TT mail list) so that Can't locate QD1/BioDatabase.pm in @INC (@INC contains: /home/dhoworth/progs/modules /home/dhoworth/progs/maypole /usr/local/lib/perl/5.6.1 /usr/local/share/perl/5.6.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.6.1 /usr/share/perl/5.6.1 /usr/local/lib/site_perl .) at (eval 48) line 3. becomes Uncaught exception from user code: Can't locate QD1/BioDatabase.pm in @INC (@INC contains: /home/dhoworth/progs/modules /home/dhoworth/progs/maypole /usr/local/lib/perl/5.6.1 /usr/local/share/perl/5.6.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.6.1 /usr/share/perl/5.6.1 /usr/local/lib/site_perl .) at (eval 48) line 3. and consequently T-P-C's RE fails to match it and T-P-C dies. It could be fixed just by removing the start of string anchor '^' but I think it could also be improved a little further using some code I adapted from Class::DBI: --- Template/Plugin/Class.pm +++ Template/Plugin/Class-new.pm @@ -13,7 +13,8 @@ eval "require $arg"; # Only ignore "Can't locate" errors from our eval require. # Other fatal errors (syntax etc) must be reported. - die if $@ && $@ !~ /^Can't locate .*? at \(eval /; + (my $filename = $arg) =~ s!::!/!g; + die if $@ && $@ !~ /Can't locate \Q$filename\E\.pm/; no strict 'refs'; unless (%{"$arg\::"}) { require Carp; That removes the start of string anchor so it works with use diagnostics and it also checks which module failed so that a load error in a use statement within the required class is not ignored. Cheers, Dave
Thanks, applied and released as 0.13 -- Richard Clamp <richardc@unixbeard.net>