Merge pull request #3293 from Icinga/bugfix/exception-chain-hidden

/error/error: show the whole exception chain
This commit is contained in:
lippserd 2018-01-19 13:21:51 +01:00 committed by GitHub
commit 2080290409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 7 deletions

View File

@ -86,9 +86,22 @@ class ErrorController extends ActionController
Logger::error("%s\n%s", $exception, $exception->getTraceAsString());
break;
}
$this->view->message = $exception->getMessage();
$this->view->messages = array();
if ($this->getInvokeArg('displayExceptions')) {
$this->view->stackTrace = $exception->getTraceAsString();
$this->view->stackTraces = array();
do {
$this->view->messages[] = $exception->getMessage();
$this->view->stackTraces[] = $exception->getTraceAsString();
$exception = $exception->getPrevious();
} while ($exception !== null);
} else {
do {
$this->view->messages[] = $exception->getMessage();
$exception = $exception->getPrevious();
} while ($exception !== null);
}
break;

View File

@ -4,9 +4,17 @@
</div>
<?php endif ?>
<div class="content">
<p tabindex="-1" class="autofocus error-message"><?= nl2br($this->escape($message)) ?></p>
<?php if (isset($stackTrace)): ?>
<hr>
<pre><?= $this->escape($stackTrace) ?></pre>
<?php endif ?>
<?php
if (isset($stackTraces)) {
foreach ($messages as $i => $message) {
echo '<p tabindex="-1" class="autofocus error-message">' . nl2br($this->escape($message)) . '</p>'
. '<hr>'
. '<pre>' . $this->escape($stackTraces[$i]) . '</pre>';
}
} else {
foreach ($messages as $message) {
echo '<p tabindex="-1" class="autofocus error-message">' . nl2br($this->escape($message)) . '</p>';
}
}
?>
</div>