Show error message and stack trace on exceptions

refs #5507
This commit is contained in:
Eric Lippmann 2014-01-22 14:57:54 +01:00
parent 6ef87f4644
commit 4473008d65
2 changed files with 15 additions and 15 deletions

View File

@ -42,26 +42,23 @@ class ErrorController extends ActionController
*/
public function errorAction()
{
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
$error = $this->_getParam('error_handler');
switch ($error->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:
// 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';
$this->view->message = $error->exception->getMessage();
break;
}
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
$this->view->stackTrace = $error->exception->getTraceAsString();
}
$this->view->request = $errors->request;
$this->view->request = $error->request;
}
}
// @codingStandardsIgnoreEnd

View File

@ -1,9 +1,12 @@
<?= $this->tabs->render($this); ?>
<div class="alert alert-error">
<h1>An error occurred</h1>
<?php if (isset($this->messageBox)) : ?>
<?= $this->messageBox->render() ?>
<? endif ?>
<div class="alert alert-danger">
<p><?= $message ?></p>
</div>
<?php if (isset($stackTrace)) : ?>
<hr />
<pre><?= $stackTrace ?></pre>
<?php endif ?>
<?php if (isset($this->messageBox)) : ?>
<?= $this->messageBox->render(); ?>
<? endif ?>
</div>