[Catalyst] Re: [again] die() in an action chain : does not breakthe chain !

Ashley apv at sedition.com
Mon Mar 17 16:25:14 GMT 2008


On Mar 17, 2008, at 1:15 AM, Dami Laurent (PJ) wrote:
> So I think something more radical is needed, at the core of the  
> chained
> actions mechanism. I tried the following modification to
> Catalyst::ActionChain
>
>    sub dispatch {
>        my ( $self, $c ) = @_;
>        my @captures = @{$c->req->captures||[]};
>        my @chain = @{ $self->chain };
>        my $last = pop(@chain);
>        foreach my $action ( @chain ) {
>            my @args;
>            if (my $cap = $action->attributes->{CaptureArgs}) {
>              @args = splice(@captures, 0, $cap->[0]);
>            }
>            local $c->request->{arguments} = \@args;
>            $action->dispatch( $c );
>
>            # ADDED LINE HERE
>            return if $c->error;
>
>        }
>        $last->dispatch( $c );
>    }
>
> and it seems to work fine. However, I don't know if this would create
> undesirable side-effects, nor if the modification above should become
> default, or something that would be toggled by a global Catalyst  
> option.


I like this idea. I've never personally needed to see three errors
when the first is usually what causes the next two anyway. Since this
would be new behavior, though, it would have to be opt-in, as you
suggest, toggled by an application configuration value.


-Ashley



More information about the Catalyst mailing list