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-tp20316623p20316699.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to