Merge pull request #24024 from nextcloud/enhancement/exception-page-full-trace

Show the full trace of an exception
This commit is contained in:
Morris Jobke 2020-11-10 13:40:16 +01:00 committed by GitHub
commit f63996f60f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 5 deletions

View File

@ -1,8 +1,24 @@
<?php <?php
/** @var array $_ */ /** @var array $_ */
/** @var \OCP\IL10N $l */ /** @var \OCP\IL10N $l */
style('core', ['styles', 'header']); style('core', ['styles', 'header']);
function print_exception(Throwable $e, \OCP\IL10N $l): void {
print_unescaped('<pre>');
p($e->getTraceAsString());
print_unescaped('</pre>');
if ($e->getPrevious() !== null) {
print_unescaped('<br />');
print_unescaped('<h4>');
p($l->t('Previous'));
print_unescaped('</h4>');
print_exception($e->getPrevious(), $l);
}
}
?> ?>
<div class="error error-wide"> <div class="error error-wide">
<h2><?php p($l->t('Internal Server Error')) ?></h2> <h2><?php p($l->t('Internal Server Error')) ?></h2>
@ -26,6 +42,6 @@ style('core', ['styles', 'header']);
<?php if (isset($_['debugMode']) && $_['debugMode'] === true): ?> <?php if (isset($_['debugMode']) && $_['debugMode'] === true): ?>
<br /> <br />
<h3><?php p($l->t('Trace')) ?></h3> <h3><?php p($l->t('Trace')) ?></h3>
<pre><?php p($_['trace']) ?></pre> <?php print_exception($_['exception'], $l); ?>
<?php endif; ?> <?php endif; ?>
</div> </div>

View File

@ -31,6 +31,7 @@
namespace OC\Template; namespace OC\Template;
use OCP\Defaults; use OCP\Defaults;
use Throwable;
class Base { class Base {
private $template; // The template private $template; // The template
@ -92,7 +93,7 @@ class Base {
/** /**
* Assign variables * Assign variables
* @param string $key key * @param string $key key
* @param array|bool|integer|string $value value * @param array|bool|integer|string|Throwable $value value
* @return bool * @return bool
* *
* This function assigns a variable. It can be accessed via $_[$key] in * This function assigns a variable. It can be accessed via $_[$key] in

View File

@ -325,7 +325,7 @@ class OC_Template extends \OC\Template\Base {
$content->assign('errorCode', $exception->getCode()); $content->assign('errorCode', $exception->getCode());
$content->assign('file', $exception->getFile()); $content->assign('file', $exception->getFile());
$content->assign('line', $exception->getLine()); $content->assign('line', $exception->getLine());
$content->assign('trace', $exception->getTraceAsString()); $content->assign('exception', $exception);
$content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false)); $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false));
$content->assign('remoteAddr', $request->getRemoteAddress()); $content->assign('remoteAddr', $request->getRemoteAddress());
$content->assign('requestID', $request->getId()); $content->assign('requestID', $request->getId());