![](/img/trans.png)
[英]How to catch my own Model Exceptions in a Zend Framework Action
[英]How to catch exceptions in an action helper?
當我在 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。
如何在動作 Controller 中捕獲異常?
ErrorHandler 插件不是為捕獲插件或助手中的錯誤而設計的:它旨在捕獲postDispatch()
事件循環中發生的錯誤,因此更適合於捕獲 MVC 中的錯誤。
這是設計使然。 您可能不應該從 controller 助手和操作助手中拋出異常,而是堅持“手動”錯誤處理。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.