My application just fell over with long error messages like that at the bottom of the message. I think I've tracked the problem down to the most excellent Template::Plugin::Class (v0.12). It tries to load the class you've 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 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 disaster in a use statement within the required class is not ignored.

Cheers, Dave

The error message was:

Uncaught exception from user code:
file error - Uncaught exception from user code:
undef error - Uncaught exception from user code:
undef error - Uncaught exception from user code:
file error - Uncaught exception from user code:
undef error - Uncaught exception from user code:
undef error - Uncaught exception from user code:
plugin error - Uncaught exception from user code:
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.
eval 'require QD1::BioDatabase
;' called at /usr/local/share/perl/5.6.1/Template/Plugin/Class.pm line 13
Template::Plugin::Class::new('Template::Plugin::Class', 'Template::Context=HASH(0x88a1044)', 'QD1::BioDatabase') called at /usr/local/lib/perl/5.6.1/Template/Plugins.pm line 119
eval {...} called at /usr/local/lib/perl/5.6.1/Template/Plugins.pm line 113
Template::Plugins::fetch('Template::Plugins=HASH(0x88a1164)', 'Class', 'ARRAY(0x8a1f5bc)', 'Template::Context=HASH(0x88a1044)') called at /usr/local/lib/perl/5.6.1/Template/Context.pm line 191
Template::Context::plugin('Template::Context=HASH(0x88a1044)', 'Class', 'ARRAY(0x8a1f5bc)') called at /var/www/qd1/custom/addnew.tt line 7
eval {...} called at /var/www/qd1/custom/addnew.tt line 7
MANY MORE LINES DELETED



_______________________________________________ templates mailing list templates@template-toolkit.org http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to