views:

34

answers:

3

Hello.

I created an ErrorController using the zend framework tool, what I don't understand is how 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

+2  A: 

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.

jakenoble
do i need to load a specific module? because i can reassure you that it does not go through the error controller.
ufk
What does the app do that makes you so sure that it is not going to the `ErrorController`? You do not need to load a specific module. Just make sure your error script and controller is in the default module.
jakenoble
+1  A: 

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?

Iznogood
unfortunately that is not the case.
ufk
edited my answer.
Iznogood
+1  A: 

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)

Jani Hartikainen