4
votes

When I throw an exception(e.g 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?

1
Setting throwExceptions to false means Zend Framework itself won't throw exceptions. Exceptions that your code throws specifically won't be affected. - Chris Laplante
Are you throwing the exception to signal the whole request that this is a HTTP Status 403 Forbidden? - hakre

1 Answers

3
votes

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.