Code:
<?php
class Default_ErrorController extends M5_Controller_Action
{
public function init()
{
$this->_acl()->allow('guest'); // allow guest access to all actions
}
public function errorAction()
{
$errors = $this->_getParam('error_handler');
if (strpos($errors->exception->getMessage(), 'SQL Server Native Client')) {
return;
}
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
$request = $this->getRequest();
$originalController = $request->getParam('controller');
$originalAction = $request->getParam('action');
if (strpos($originalController, '.php') || strpos($originalAction, '.php')) {
$this->_redirector()->gotoRoute(array('menu_id'=> App_MenuIds::HOME), 'postSlug');
exit;
}
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found';
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error';
Zend_Debug::setSapi('cli');
if (function_exists('xdebug_disable')) {
xdebug_disable();
}
$arguments = array();
$stack = $e->getTrace(); <-------THIS IS THE LINE!!!
foreach ($stack as $trace) {
$name = $trace['class'] . $trace['type'] . $trace['function'];
$arguments[$name] = array();
foreach ($trace['args'] as $arg) {
if (!is_object($arg)) {
$arguments[$name][] = $arg;
} else {
$arguments[$name][] = get_class($arg);
}
}
}
etc...
The error received is:-
Notice: Undefined variable: e in xxxx.php on line 46
Fatal error: Call to a member function getTrace() on a non-object in xxxx.php on line 46
Fatal error: Call to a member function getTrace() on a non-object in xxxx.php on line 46
So is it the fact e isn't defined before that line:-
$stack = $e->getTrace();
How should it be defined? Or is the code expecting that to have been set elsewhere in the program for that line to then be use when this subroutine is called?
Thanks in advance!