Subject: | Improved error message for missing tables |
If you include a table name in your call to BeerDB->display_tables() that does not exist in the database, Maypole::Plugin::AutoUntaint->auto_untaint will die with an error similar to 'Can't call method "auto_untaint" on an undefined value at C:/Perl/site/lib/Maypole/Plugin/AutoUntaint.pm line 143.\n' because the class you are trying to untaint is not defined.
It can be hard to see at a glance which table name caused the error, particularly if you display a lot of tables.
Attached AutoUntaint.diff simply adds a check to see if a class exists, and if not dies with an error that includes the offending table name. Nice and easy to debug :)
--- AutoUntaint.pm Tue Jun 28 12:22:50 2005
+++ AutoUntaint_new.pm Tue Jun 28 12:23:15 2005
@@ -139,7 +139,7 @@
$targs{strict} = 1 unless $r->debug;
my $class = $r->config->loader->find_class( $table );
-
+ die "no class exists for table '$table'" if !$class;
$class->auto_untaint( %targs );
}
}