-- SiCo007 <[EMAIL PROTECTED]> wrote
(on Sunday, 28 October 2007, 06:22 AM -0700):
>
> I would of thought this is probably quite easy I just can't grasp it.
>
> How do I throw an exception in my plugin (in preDispatch) and get it caught
> by the errorHandler plugin?
>
> Basically I want to force a 404 and as it's handled in the errorHandler
> anyway it seemed the logical route?!
At this point, the error handler only handles exceptions based on
dispatching and your own application logic -- i.e., if the controller or
action was not found, or if your controller code threw an exception.
In the scenario you descrive, in a preDispatch() plugin, you can simply
forward to the ErrorController:
$this->getRequest()
->setModuleName('default')
->setControllerName('error')
->setActionName('error')
->setParams('error', $error)
->setDispatched(false);
In the above example, I'm setting an 'error' parameter, and I'd alter
the ErrorController::errorAction() method to look for that if no
error_handler parameter is found.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/