如何在操作助手中捕获异常



当我在Action Helper中抛出异常(例如throw new Zend_Exception('You are not allowed',403);)时,ErrorHandler不会捕捉到它。我得到了Fatal error: Uncaught exception 'Zend_Exception' with message 'You are not allowed' in..

我还在frontController中设置了throwExceptions=false。

如何在Action Controller中捕获异常?

ErrorHandler插件不是为捕捉插件或助手中的错误而设计的:它是为捕捉postDispatch()事件循环中发生的错误而设的,因此更适合捕捉MVC中的错误。

这是经过设计的。您可能不应该从控制器助手和操作助手中抛出异常,而应该坚持"手动"错误处理。

最新更新