Skip to content
Snippets Groups Projects
Commit d64fc212 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Meilleur affichage des traces pou déboguer

parent eead7aee
Branches
Tags
No related merge requests found
......@@ -417,6 +417,29 @@ class Util
return $result;
}
static public function formatTraceString( $trace )
{
$result = '';
$trace = explode( "\n", $trace );
foreach( $trace as $index => $line ){
preg_match( '/^#([0-9]+) (.*): (.*)/', $line, $elements );
if (4 == count($elements)){
$index = $elements[1];
$file = $elements[2];
$code = $elements[3];
if (class_exists('\Test\Util')){
$code = \Test\Util::highlight($code, true);
}
$inVendor = false !== strpos($line, '/vendor/');
$result .= '<div style="'.($inVendor ? 'color:#aaa;' : '' ).'white-space:nowrap">'.$index.' '.$file.'</div>';
$result .= '<div style="margin-left:5em;margin-bottom:3px">'.$code.'</div>';
}else{
$result .= '<div style="white-space:nowrap">'.substr( $line, 1 ).'</div>';
}
}
return $result;
}
/**
* Extrait les feuilles d'un arbre.
*
......
......@@ -71,7 +71,7 @@ class Messenger extends AbstractHelper
return $this->render();
}
catch (\Exception $exc) {
var_dump($exc->getMessage(), $exc->getTraceAsString());die;
var_dump($exc->getMessage(), \UnicaenApp\Util::formatTraceString($exc->getTraceAsString()));die;
}
}
......
......@@ -59,7 +59,7 @@
<h3><?php echo $this->translate('Stack trace') ?>:</h3>
<pre>
<?php echo $this->exception->getTraceAsString() ?>
<?php echo \UnicaenApp\Util::formatTraceString($this->exception->getTraceAsString()) ?>
</pre>
<?php endif ?>
......
......@@ -27,7 +27,7 @@
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getTraceAsString() ?></pre>
<pre class="prettyprint linenums"><?php echo \UnicaenApp\Util::formatTraceString($this->exception->getTraceAsString()) ?></pre>
</dd>
</dl>
<?php
......@@ -51,7 +51,7 @@
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getTraceAsString() ?></pre>
<pre class="prettyprint linenums"><?php echo \UnicaenApp\Util::formatTraceString($e->getTraceAsString()) ?></pre>
</dd>
</dl>
</li>
......
......@@ -20,7 +20,7 @@
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getTraceAsString() ?></pre>
<pre class="prettyprint linenums"><?php echo \UnicaenApp\Util::formatTraceString($this->exception->getTraceAsString()) ?></pre>
</dd>
</dl>
<?php
......@@ -44,7 +44,7 @@
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getTraceAsString() ?></pre>
<pre class="prettyprint linenums"><?php echo \UnicaenApp\Util::formatTraceString($e->getTraceAsString()) ?></pre>
</dd>
</dl>
</li>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment