Skip to content
Snippets Groups Projects
Unverified Commit 979b291a authored by Christoph Wurst's avatar Christoph Wurst
Browse files

Show the full trace of an exception


Because often we catch the exception at some point and then the trace is
misleading. What's really interesting is the trace of the *previous*
exception.

Signed-off-by: default avatarChristoph Wurst <christoph@winzerhof-wurst.at>
parent 78e1f228
No related branches found
No related tags found
No related merge requests found
<?php
/** @var array $_ */
/** @var \OCP\IL10N $l */
/** @var array $_ */
/** @var \OCP\IL10N $l */
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">
<h2><?php p($l->t('Internal Server Error')) ?></h2>
......@@ -26,6 +42,6 @@ style('core', ['styles', 'header']);
<?php if (isset($_['debugMode']) && $_['debugMode'] === true): ?>
<br />
<h3><?php p($l->t('Trace')) ?></h3>
<pre><?php p($_['trace']) ?></pre>
<?php print_exception($_['exception'], $l); ?>
<?php endif; ?>
</div>
......@@ -31,6 +31,7 @@
namespace OC\Template;
use OCP\Defaults;
use Throwable;
class Base {
private $template; // The template
......@@ -92,7 +93,7 @@ class Base {
/**
* Assign variables
* @param string $key key
* @param array|bool|integer|string $value value
* @param array|bool|integer|string|Throwable $value value
* @return bool
*
* This function assigns a variable. It can be accessed via $_[$key] in
......
......@@ -325,7 +325,7 @@ class OC_Template extends \OC\Template\Base {
$content->assign('errorCode', $exception->getCode());
$content->assign('file', $exception->getFile());
$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('remoteAddr', $request->getRemoteAddress());
$content->assign('requestID', $request->getId());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment