[Catalyst] $c->forward and Exception
Yann Kerherve
yann at cyberion.net
Thu Feb 23 00:42:59 CET 2006
On 27 janv. 06, at 14:36, Tatsuhiko Miyagawa wrote:
Hi,
Just to revive this old thread...
> I have a Catalyst app which code goes like:
>
> sub foo : Local {
> my($self, $c) = @_;
> $c->forward('bar');
> do_something();
> }
>
> sub bar : Private {
> my($self, $c) = @_;
> throw My::Exception() if cond();
> }
>
> I thought do_something() is not executed when bar throws an Excpetion.
> But it wasn't true. Because forward() is executed in eval {} and
> excpetion is set to $c->error, do_something() *is* executed.
>
> Apparently, I have to write something like:
>
> $c->forward('bar');
> die $c->error if $c->error;
>
> everywhere, to make forward() DWIM.
I've implemented a Plugin to DWMSM (Do What Miyagawa-san Means) based
on discussions at Six Apart, It's temporarily hosted here :
http://cyberion.net/mortalforward/
and I'd love to have your feedback. Pod is here :
http://cyberion.net/mortalforward/Catalyst-Plugin-
MortalForward-0.01/lib/Catalyst/Plugin/MortalForward.pm
Yann
More information about the Catalyst
mailing list