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() public function errorAction()
{ {
$errors = $this->_getParam('error_handler'); $error = $this->_getParam('error_handler');
switch ($errors->type) { switch ($error->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404); $this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found'; $this->view->message = 'Page not found';
break; break;
default: default:
// application error
$this->getResponse()->setHttpResponseCode(500); $this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error'; $this->view->message = $error->exception->getMessage();
break; break;
} }
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) { 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 // @codingStandardsIgnoreEnd

View File

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