[Catalyst-commits] r9085 - in Catalyst-Runtime/5.80/trunk: . lib
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Tue Jan 13 23:38:45 GMT 2009
Author: t0m
Date: 2009-01-13 23:38:45 +0000 (Tue, 13 Jan 2009)
New Revision: 9085
Modified:
Catalyst-Runtime/5.80/trunk/Changes
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Log:
Merge up from 5.70 trunk:
r9031 | jhannah | 2009-01-07 19:51:06 +0000 (Wed, 07 Jan 2009) | 5 lines
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.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes 2009-01-13 23:38:36 UTC (rev 9084)
+++ Catalyst-Runtime/5.80/trunk/Changes 2009-01-13 23:38:45 UTC (rev 9085)
@@ -1,6 +1,8 @@
# This file documents the revision history for Perl extension Catalyst.
5.8000_05
+ - Improve the clarity and verbosity of the warning when component
+ resolution uses regex fallback. (jhannah)
- Handle leading CRLF in HTTP requests sometimes sent by IE6 in
keep-alive requests. (andyg)
- Fixes for FastCGI with IIS 6.0 (janus)
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-01-13 23:38:36 UTC (rev 9084)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-01-13 23:38:45 UTC (rev 9085)
@@ -30,7 +30,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; }
@@ -510,9 +510,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;
@@ -613,7 +628,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' );
@@ -752,7 +767,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 );
@@ -2546,6 +2561,8 @@
jcamacho: Juan Camacho
+jhannah: Jay Hannah <jay at jays.net>
+
Jody Belka
Johan Lindstrom
More information about the Catalyst-commits
mailing list