When I throw an exception from dispatchLoopStartup I get the following output: ___ Application Error this is index view
This is error view The following error occurred: exception 'Zend_Exception' with message 'test' ___ So its catching the exception but both the index action from the index controller and error action from the error controller are called, both views are rendered also. This is all looking very similar to the following logged bug (marked as resolved): http://framework.zend.com/issues/browse/ZF-2461 Waigani wrote: > > correction, it is catching the exception when thrown from > dispatchLoopStartup from my plugin, but not whe it is thrown from > preDispatch. Is this the expected behaviour? > > > > Waigani wrote: >> >> throw exceptions is not on and I've also tested the dispatchLoopStartup >> in the plugins broker. It is not catching the exception. >> >> >> >> Waigani wrote: >>> >>> The code >>> >>> throw new Zend_Exception('test'); >>> >>> in the predispatch hook of a plugin returns >>> >>> Fatal error: Uncaught exception 'Zend_Exception' with message 'test' … >>> >>> I am registering my plugins via $frontController->registerPlugin() >>> method. >>> >>> Is this not the expected behaviour? >>> >>> >>> >>> Jason Webster wrote: >>>> >>>> The Plugin Broker (Zend_Controller_Plugin_Broker) _should_ catch any >>>> exceptions thrown by controller plugins. Well, not should, it does. >>>> Perhaps this is an issue with how you're instantiating your plugins?? >>>> >>>> Waigani wrote: >>>>> Thanks for the run down. Is it possible to throw an error in a plugin >>>>> though? >>>>> So far the errorController has missed it. >>>>> >>>>> >>>>> >>>>> Jason Webster wrote: >>>>> >>>>>> Waigani wrote: >>>>>> >>>>>>> Is it possible? I want to throw an exception in the preDispatch of a >>>>>>> plugin >>>>>>> if you are not allowed to view the page. I then want to handle that >>>>>>> exception via the errorController. I can wrap the $front->dispatch() >>>>>>> in a >>>>>>> try / catch and catch the exception in the bootstrap, but then how >>>>>>> do I >>>>>>> forward that onto the errorController, as the front controller has >>>>>>> not >>>>>>> been >>>>>>> dispatched? I've read the manual and other posts and have not found >>>>>>> an >>>>>>> answer nor an alternative method. >>>>>>> >>>>>>> >>>>>> I think you may be misunderstanding the dispatching process of the >>>>>> front >>>>>> controller. Here's a run down: >>>>>> >>>>>> 1. Request/Response/Router/Dispatcher initialization >>>>>> 2. routeStartup() >>>>>> * call plugins registered with this hook >>>>>> 3. Routing >>>>>> * Updates Request object based on matched information from >>>>>> routing >>>>>> 4. routeShutdown() >>>>>> * call plugins registered with this hook >>>>>> 5. dispatchLoopStartup() >>>>>> * call plugins registered with this hook >>>>>> 6. preDispatch() >>>>>> * call plugins registered with this hook >>>>>> 7. Dispatch action >>>>>> 8. action helper preDispatch() >>>>>> 9. action controller preDispatch() >>>>>> 10. action method >>>>>> * UNLESS a _forward() or redirect has occurred >>>>>> 11. action controller postDispatch() >>>>>> 12. action helper postDispatch() >>>>>> 13. postDispatch() >>>>>> * call plugins registered with this hook >>>>>> /* repeat 6 - 13 as necessary */ >>>>>> 14. dispatchLoopShutdown() >>>>>> * call plugins registered with this hook >>>>>> 15. send response >>>>>> >>>>>> The preDispatch hooks of action helpers and action controllers ad re >>>>>> steps 8 and 9, respectively. The ErrorHandler front controller plugin >>>>>> is >>>>>> registered basically right away. >>>>>> >>>>>> In short, if you throw an exception in the preDispatch of a >>>>>> controller/action it _will_ be caught by the ErrorHandler plugin, and >>>>>> thus forwarded to the error controller. >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>>> >>> >>> >> >> > > -- View this message in context: http://www.nabble.com/handle-any-exception-with-errorController-tp20316623p20319028.html Sent from the Zend Framework mailing list archive at Nabble.com.
