Subject: | Behavior of $c->state inside $c->execute differs significantly from documentation |
Date: | Thu, 26 May 2016 14:51:34 +0530 |
To: | bug-Catalyst-Runtime [...] rt.cpan.org |
From: | Chase Venters <chase.venters [...] gmail.com> |
Greetings,
Commit e459bd036c9076bd7301ea2fbdd5d4ba9900ddf0 to Catalyst::Runtime
introduced a regression to our Catalyst code bases.
We use a controller action, "authenticate" to check authentication
credentials on web service endpoints called on our app. Because the
behavior of $c->forward() is to wrap the action in eval { }, we followed
the advice in the documentation to call $c->forward like this:
$c->forward('authenticate') || return;
This used to work just fine. Unfortunately, after the aforementioned
commit, $c->state() is not set to 0. The line(s) setting $c->state to 0 are
commented out in that commit along with the message "preserve $c->state".
The unfortunate effect of this is that if we throw an exception inside our
authenticate action, it is now short circuiting and allowing control flow
to continue, despite our exception.
For now, we resolved the issue by returning if $c->has_errors but it seems
that this commit should either be reverted, or the documentation updated to
reflect the fact that checking the $c->forward() return value is no longer
a reliable way to handle exceptions.
Thanks,
Chase