[Catalyst] $c->forward and don't come back?

Sebastian Riedel sri at oook.de
Thu Jun 9 20:30:36 CEST 2005


Am 09.06.2005 um 20:28 schrieb Christopher Heschong:

> I keep find myself often wanting to do the following:
>
> sub foo : Local
> {
>    my ($self, $c, $id) = @_;
>
>    MyApp::M::CDBI::Table->retrieve($id)
>       or $c->forward('error');
>
>    $c->stash->{template} = 'foo.tmpl';
>
> }
>
>
> sub error : Local
> {
>    my ($self, $c) = @_;
>    $c->stash->{template} = 'error.tmpl';
> }
>
>
> The problem is, when I forward over to error, it does its work and  
> then
> comes back and finishes processing foo, setting the template to
> 'foo.xhtml'.  Is there something like forward that doesn't come  
> back?  I
> know there is $c->redirect but if I'm not mistaken that sends an HTTP
> redirect, which isn't exactly what I was hoping for.

*cough*

     MyApp::M::CDBI::Table->retrieve($id) or return $c->forward 
('error');

--
sebastian




More information about the Catalyst mailing list