From what I understand, _forward only modifies the request and resets its
dispatched flag. In other words, you can't catch any exception thrown in the
action because the action isn't actually dispatched at that point.
Generally, exceptions thrown by actions are caught in the ErrorHandler
plugin and forwarded to the ErrorController. Can you handle your error in
the ErrorController?
--
Hector
On Wed, Oct 28, 2009 at 10:26 AM, Cadrach <masterachid@yahoo.com> wrote:
>
> Hi everyone,
>
> I have the following issue, inside an action I would like to catch the
> Exception thrown inside a $this->_forward I am making.
>
> Example code of my controller:
> public function initAction()
> {
> $this->getFrontController()->setParam('noErrorHandler', true);
> $this->getFrontController()->throwExceptions(true);
> try
> {
> $this->_forward('test');
> }
> catch(Exception $e)
> {
> echo "CAUGHT";
> exit;
> }
> }
>
> public function testAction()
> {
> throw new Exception('TEST');
> }
>
> This code displays the exception using standard PHP display, but the
> "catch"
> is never run.
>
> Any idea what I am doing wrong? Or is this the excepted behavior of
> _forward()?
>
> Thanks for reading,
> Cadrach
> --
> View this message in context:
>
http://www.nabble.com/Catching-Exception-thrown-in-_forward-tp26098718p26098718.html> Sent from the Zend MVC mailing list archive at Nabble.com.
>
>