I am currently using a basic error controller that looks like this:
class ErrorController extends My_MyController
{
public function errorAction()
{
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
$this->getResponse()
->setRawHeader('HTTP/1.1 404 Not Found');
$this->view->headTitle('HTTP/1.1 404 Not Found');
$this->view->message = 'HTTP/1.1 404 Not Found';
break;
default:
$exception = $errors->exception;
$log = new Zend_Log(
new Zend_Log_Writer_Stream(
BASE_PATH . '/logs/applicationException.log'
)
);
$log->debug($exception->getMessage() . "\n" .
$exception->getTraceAsString());
$this->view->headTitle('HTTP/1.1 404 Not Found');
$this->view->message = 'Application error';
break;
}
$this->view->exception = $errors->exception;
}
}
This, however, only catches and logs application exceptions. It does not register any warnings, notifications, and fatal errors.
I would also like to register them. Is there a recommended way to do this in ErrorController? Or should it be done outside the ErrorController in index.php (since the Zend Framework ErrorHandler will only handle the route, missing exceptions for the application / action and exceptions in the action controllers)?
source
share