zend framework php ErrorController: how do i throw an expection that will be shown in the Error Controller
I created an ErrorController using the zend framework tool, what I don't understand is h开发者_开发问答ow do i actually use it?
I want instead of throwing an Exception that will shown on the screen, to throw an error that will be shown in the Error Controller.
using Zend Framework v1.10.7
any ideas?
thanks
Throwing an exception that is not caught in your application will result in it being handled by the ErrorController
. The default behavior is for it to be handled by the ErrorController
.
The exception that is shown on screen is probably already routed thru the errorController. Go in your views folder there should be a error folder with the view script for errors. Go in there if you want to style them.
Ok so you ar enot seeing anything after enabling the errorController from zedntool.
Looking at your folders is the a ErrorController.php in your Apllication/Controllers directory?
Is the a error folders in you views folder with a index.phtml file in it?
Looking at your application.ini file. Are these lines properly set?
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
How you know it doesnt work?
For the exception to be caught into the error controller two things must be true:
- You're throwing the exception in code that is run inside a controller. It will not work inside say controller plugins
- You have throwExceptions disabled in front controller (
$fc->throwExceptions(false)
)
If these two conditions are true for your case, and it's still not working, then you need to provide some more information on what you're doing and what is the result you're getting (exact output, exact code)
精彩评论