X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;h=94dd80d97dd04064bcf91625d021526be9032465;hb=0a0a7a2289bc879cc1714db5b4ce07fb1088813d;hp=6f86968697594629e2581e2586609a6eb0863fb0;hpb=7ace516e7f6bd9ab825f8497e42bf72bbda90926;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 6f86968..94dd80d 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -121,7 +121,9 @@ sub forward { unless ( @{$results} ) { my $class = $command; if ( $class =~ /[^\w\:]/ ) { - $c->log->debug(qq/Couldn't forward to "$class"/) if $c->debug; + my $error = qq/Couldn't forward to "$class"/; + $c->error($error); + $c->log->debug($error) if $c->debug; return 0; } my $method = shift || 'process'; @@ -130,7 +132,9 @@ sub forward { $results = [ [ [ $class, $code ] ] ]; } else { - $c->log->debug(qq/Couldn't forward to "$class->$method"/) + my $error = qq/Couldn't forward to "$class->$method"/; + $c->error($error); + $c->log->debug($error) if $c->debug; return 0; } @@ -231,6 +235,12 @@ sub set_action { elsif ( $attr =~ /^(Regex|Regexp)\((.+)\)$/i ) { $flags{regex} = $2 } } + if ( $flags{private} && ( keys %flags > 1 ) ) { + $c->log->error( 'Bad action definition "' + . join( ' ', @{$attrs} ) + . qq/" for "$namespace->$method"/ ); + return; + } return unless keys %flags; my $parent = $c->tree; @@ -320,18 +330,11 @@ sub setup_actions { } } } - my $t = Text::ASCIITable->new( { hide_HeadRow => 1, hide_HeadLine => 1 } ); - $t->setCols('Class'); - $t->setColWidth( 'Class', 75, 1 ); - $t->addRow( wrap( $_, 75 ) ) for keys %{ $self->components }; - $self->log->debug( 'Loaded components', $t->draw ) - if ( @{ $t->{tbl_rows} } && $self->debug ); my $actions = $self->actions; my $privates = Text::ASCIITable->new; - $privates->setCols( 'Private', 'Class', 'Code' ); - $privates->setColWidth( 'Private', 28, 1 ); - $privates->setColWidth( 'Class', 27, 1 ); - $privates->setColWidth( 'Code', 15, 1 ); + $privates->setCols( 'Private', 'Class' ); + $privates->setColWidth( 'Private', 36, 1 ); + $privates->setColWidth( 'Class', 37, 1 ); my $walker = sub { my ( $walker, $parent, $prefix ) = @_; $prefix .= $parent->getNodeValue || ''; @@ -339,11 +342,8 @@ sub setup_actions { my $uid = $parent->getUID; for my $action ( keys %{ $actions->{private}->{$uid} } ) { my ( $class, $code ) = @{ $actions->{private}->{$uid}->{$action} }; - $privates->addRow( - wrap( "$prefix$action", 28 ), - wrap( $class, 27 ), - wrap( $code, 15 ) - ); + $privates->addRow( wrap( "$prefix$action", 36 ), + wrap( $class, 37 ) ); } $walker->( $walker, $_, $prefix ) for $parent->getAllChildren; }; @@ -352,25 +352,25 @@ sub setup_actions { if ( @{ $privates->{tbl_rows} } && $self->debug ); my $publics = Text::ASCIITable->new; $publics->setCols( 'Public', 'Private' ); - $publics->setColWidth( 'Public', 37, 1 ); - $publics->setColWidth( 'Private', 36, 1 ); + $publics->setColWidth( 'Public', 36, 1 ); + $publics->setColWidth( 'Private', 37, 1 ); for my $plain ( sort keys %{ $actions->{plain} } ) { my ( $class, $code ) = @{ $actions->{plain}->{$plain} }; my $reverse = $self->actions->{reverse}->{$code}; $reverse = $reverse ? "/$reverse" : $code; - $publics->addRow( wrap( "/$plain", 37 ), wrap( $reverse, 36 ) ); + $publics->addRow( wrap( "/$plain", 36 ), wrap( $reverse, 37 ) ); } $self->log->debug( 'Loaded public actions', $publics->draw ) if ( @{ $publics->{tbl_rows} } && $self->debug ); my $regexes = Text::ASCIITable->new; $regexes->setCols( 'Regex', 'Private' ); - $regexes->setColWidth( 'Regex', 37, 1 ); - $regexes->setColWidth( 'Private', 36, 1 ); + $regexes->setColWidth( 'Regex', 36, 1 ); + $regexes->setColWidth( 'Private', 37, 1 ); for my $regex ( sort keys %{ $actions->{regex} } ) { my ( $class, $code ) = @{ $actions->{regex}->{$regex} }; my $reverse = $self->actions->{reverse}->{$code}; $reverse = $reverse ? "/$reverse" : $code; - $regexes->addRow( wrap( $regex, 37 ), wrap( $reverse, 36 ) ); + $regexes->addRow( wrap( $regex, 36 ), wrap( $reverse, 37 ) ); } $self->log->debug( 'Loaded regex actions', $regexes->draw ) if ( @{ $regexes->{tbl_rows} } && $self->debug );