2 // application/controllers/ErrorController.php
7 class ErrorController
extends Zend_Controller_Action
10 * errorAction() is the action that will be called by the "ErrorHandler"
11 * plugin. When an error/exception has been encountered
12 * in a ZF MVC application (assuming the ErrorHandler has not been disabled
13 * in your bootstrap) - the Errorhandler will set the next dispatchable
14 * action to come here. This is the "default" module, "error" controller,
15 * specifically, the "error" action. These options are configurable.
17 * @see http://framework.zend.com/manual/en/zend.controller.plugins.html
21 public function errorAction()
23 // Ensure the default view suffix is used so we always return good
25 $this->_helper
->viewRenderer
->setViewSuffix('phtml');
27 // Grab the error object from the request
28 $errors = $this->_getParam('error_handler');
30 // $errors will be an object set as a parameter of the request object,
32 switch ($errors->type
) {
33 case Zend_Controller_Plugin_ErrorHandler
::EXCEPTION_NO_CONTROLLER
:
34 case Zend_Controller_Plugin_ErrorHandler
::EXCEPTION_NO_ACTION
:
36 // 404 error -- controller or action not found
37 $this->getResponse()->setHttpResponseCode(404);
38 $this->view
->message
= 'Page not found';
42 $this->getResponse()->setHttpResponseCode(500);
43 $this->view
->message
= 'Application error';
47 // pass the environment to the view script so we can conditionally
48 // display more/less information
49 $this->view
->env
= $this->getInvokeArg('env');
51 // pass the actual exception object to the view
52 $this->view
->exception
= $errors->exception
;
54 // pass the request to the view
55 $this->view
->request
= $errors->request
;