[Catalyst-commits] r9031 - Catalyst-Runtime/5.70/trunk/lib
jhannah at dev.catalyst.perl.org
jhannah at dev.catalyst.perl.org
Wed Jan 7 19:51:06 GMT 2009
Author: jhannah
Date: 2009-01-07 19:51:06 +0000 (Wed, 07 Jan 2009)
New Revision: 9031
Modified:
Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm
Log:
Far more verbose error messages. Does great at making the problem in my
Catalyst/Plugin/Session/Store/DBIC.pm configuration super obvious.
Hopefully this also makes other mistakes more obvious. I'm not sure it's
perfect, but I think it's better than it was. --jay at jays.net
Modified: Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm 2009-01-07 19:16:37 UTC (rev 9030)
+++ Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm 2009-01-07 19:51:06 UTC (rev 9031)
@@ -26,7 +26,7 @@
use Tree::Simple::Visitor::FindByUID;
use attributes;
use utf8;
-use Carp qw/croak carp/;
+use Carp qw/croak carp shortmess/;
BEGIN { require 5.008001; }
@@ -446,9 +446,24 @@
# don't warn if we didn't find any results, it just might not exist
if( @result ) {
- $c->log->warn( qq(Found results for "${name}" using regexp fallback.) );
- $c->log->warn( 'Relying on the regexp fallback behavior for component resolution is unreliable and unsafe.' );
- $c->log->warn( 'If you really want to search, pass in a regexp as the argument.' );
+ my $msg = "Used regexp fallback for \$c->model('${name}'), which found '" .
+ (join '", "', @result) . "'. Relying on regexp fallback behavior for " .
+ "component resolution is unreliable and unsafe.";
+ my $short = $result[0];
+ $short =~ s/.*?Model:://;
+ my $shortmess = Carp::shortmess('');
+ if ($shortmess =~ m#Catalyst/Plugin#) {
+ $msg .= " You probably need to set '$short' instead of '${name}' in this " .
+ "plugin's config";
+ } elsif ($shortmess =~ m#Catalyst/lib/(View|Controller)#) {
+ $msg .= " You probably need to set '$short' instead of '${name}' in this " .
+ "component's config";
+ } else {
+ $msg .= " You probably meant \$c->model('$short') instead of \$c->model{'${name}'}, " .
+ "but if you really wanted to search, pass in a regexp as the argument " .
+ "like so: \$c->model(qr/${name}/)";
+ }
+ $c->log->warn( "${msg}$shortmess" );
}
return @result;
@@ -549,7 +564,7 @@
my( $comp, $rest ) = $c->_comp_search_prefixes( undef, qw/Model M/);
if( $rest ) {
- $c->log->warn( 'Calling $c->model() will return a random model unless you specify one of:' );
+ $c->log->warn( Carp::shortmess('Calling $c->model() will return a random model unless you specify one of:') );
$c->log->warn( '* $c->config->{default_model} # the name of the default model to use' );
$c->log->warn( '* $c->stash->{current_model} # the name of the model to use for this request' );
$c->log->warn( '* $c->stash->{current_model_instance} # the instance of the model to use for this request' );
@@ -688,7 +703,7 @@
return map { $c->_filter_component( $_, @args ) } @result if ref $name;
if( $result[ 0 ] ) {
- $c->log->warn( qq(Found results for "${name}" using regexp fallback.) );
+ $c->log->warn( Carp::shortmess(qq(Found results for "${name}" using regexp fallback)) );
$c->log->warn( 'Relying on the regexp fallback behavior for component resolution' );
$c->log->warn( 'is unreliable and unsafe. You have been warned' );
return $c->_filter_component( $result[ 0 ], @args );
@@ -2501,6 +2516,8 @@
jcamacho: Juan Camacho
+jhannah: Jay Hannah <jay at jays.net>
+
Jody Belka
Johan Lindstrom
More information about the Catalyst-commits
mailing list