简体   繁体   中英

How to catch exceptions in an action helper?

When I throw an exception(eg throw new Zend_Exception('You are not allowed',403); ) in Action Helper, ErrorHandler won't catch it. I got Fatal error: Uncaught exception 'Zend_Exception' with message 'You are not allowed' in.. .

I've also set up throwExceptions = false in frontController.

How to catch exceptions in Action Controller?

The ErrorHandler plugin is not designed for catching errors in plugins or helpers: it is designed to catch errors that occur in the postDispatch() event loop, and thus, is more suitable for catching errors in your MVC.

This is by design. You should probably not throw exceptions from within controller helpers and action helpers and stick to 'manual' error handling instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM