X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;h=91e39a5845e4059f0bc9681ce913c67ece1156a6;hb=d837e1a7eadff19ff04373ad19d22fa293e19db5;hp=c0daccd14e8112f722d0248642311122fe3f1070;hpb=2d752b2a8829f424075d4619e9d4edd852adbf46;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index c0daccd..91e39a5 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -65,16 +65,15 @@ sub dispatch { } # Execute the auto chain - my $auto = 0; - for my $auto ( @{ $c->get_action( 'auto', $namespace ) } ) { + my $auto; + for $auto ( @{ $c->get_action( 'auto', $namespace ) } ) { $c->execute( @{ $auto->[0] } ); return if scalar @{ $c->error }; last unless $c->state; - $auto++; } # Execute the action or last default - my $mkay = $auto ? $c->state ? 1 : 0 : 1; + my $mkay = defined $auto ? $c->state ? 1 : 0 : 1; if ( ( my $action = $c->req->action ) && $mkay ) { if ( my $result = @{ $c->get_action( $action, $default ) }[-1] ) { $c->execute( @{ $result->[0] } ); @@ -135,9 +134,20 @@ sub forward { unless ( @{$results} ) { my $class = $command || ''; + my $path = $class . '.pm'; + $path =~ s/::/\//g; - if ( $class =~ /[^\w\:]/ ) { - my $error = qq/Couldn't forward to "$class"/; + unless ( $INC{$path} ) { + my $error = + qq/Couldn't forward to "$class". Invalid or not loaded./; + $c->error($error); + $c->log->debug($error) if $c->debug; + return 0; + } + + unless ( UNIVERSAL::isa( $class, 'Catalyst::Base' ) ) { + my $error = + qq/Can't forward to "$class". Class is not a Catalyst component./; $c->error($error); $c->log->debug($error) if $c->debug; return 0; @@ -151,7 +161,8 @@ sub forward { } else { - my $error = qq/Couldn't forward to "$class"/; + my $error = + qq/Couldn't forward to "$class". Does not implement "$method"/; $c->error($error); $c->log->debug($error) if $c->debug; @@ -345,7 +356,7 @@ sub setup_actions { for my $comp (@$comps) { $comp = ref $comp || $comp; - for my $action ( @{ $comp->_cache } ) { + for my $action ( @{ Catalyst::Utils::reflect_actions($comp) } ) { my ( $code, $attrs ) = @{$action}; my $name = ''; no strict 'refs';