Added support for non C::Base components to live in MyApp namespace
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Dispatcher.pm
index ab305ec..33d497f 100644 (file)
@@ -135,13 +135,22 @@ sub forward {
 
     unless ( @{$results} ) {
         my $class = $command || '';
+        my $path  = $class . '.pm';
+        $path =~ s/::/\//g;
 
-        if ( $class =~ /[^\w\:]/ ) {
-            my $error = qq/"$class" is an invalid Class name/;
+        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;            
+        }
 
         my $method = shift || 'process';