views:

1984

answers:

5

This is my first experience using the Zend Framework. I am attempting to follow the Quick Start tutorial. Everything was working as expected until I reached the section on the Error Controller and View. When I navigate to a page that does not exist, instead of receiving the error page I get the Fatal Error screen dump (in all it's glory):

Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in /home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Dispatcher/Standard.php:249 Stack trace: #0 /home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /home/.fantasia/bcnewman/foo.com/public/index.php(42): Zend_Controller_Front->dispatch() #2 {main} thrown in /home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Dispatcher/Standard.php on line 249

I do not believe this is caused by a syntax error on my part (a copied and pasted the example file's content from the tutorial) and I believe I have the application directory structure correct:

./application
./application/controllers
./application/controllers/IndexController.php
./application/controllers/ErrorHandler.php
./application/views
./application/views/scripts
./application/views/scripts/index
./application/views/scripts/index/index.phtml
./application/views/scripts/error
./application/views/scripts/error/error.phtml
./application/bootstrap.php
./public
./public/index.php

And finally, the IndexController and index.phtml view does work. Many thanks in advance. ~b

+2  A: 

Assuming that you have the ErrorController plugin loaded into your front controller, make sure that in your bootstrap that you do not have the following set:

$frontController->throwExceptions(true);

If this is set then Exceptions will always be thrown, regardless of whether or not you have an error controller set.

dragonmantank
Had the same issue as OP and this was my problem. Thanks! Forgot I left that in there.
leek
+4  A: 

You have ErrorHandler.php. It should be ErrorController.php. Controllers all need to be named following the format of NameController.php. Since you don't have it named properly the dispatcher cannot find it.

gaoshan88
Definite user error. Thanks for the second pair of eyes. ~b
brian newman
A: 

yeah! that was my problem, too! :)

thanks @dragonmantank

A: 

thanks, it helped!!

Aneesh
A: 

I'm running into a similar problem. My errorcontroller is set up and functioning great except for timeouts "Fatal error: Maximum execution time of 30 seconds exceeded".

This application I'm coding calls a series of SOAP requests. And if the SOAP call times out, the errorController doesn't get called and instead i just get the fatal error.

In all other error cases (404s due to missing controllers, calls to missing functions, etc), the errorController fires off as it should.

Any ideas?

brian