Fix issues with stack trace output.

Traces without files and without classes caused errors in printing
the fancy trace.
This commit is contained in:
mark_story 2011-12-07 21:19:57 -05:00
parent 545694d84b
commit 123a1a21ba

View file

@ -29,12 +29,14 @@ App::uses('Debugger', 'Utility');
printf( printf(
'<a href="#" onclick="traceToggle(event, \'file-excerpt-%s\')">%s line %s</a>', '<a href="#" onclick="traceToggle(event, \'file-excerpt-%s\')">%s line %s</a>',
$i, $i,
$stack['file'], Debugger::trimPath($stack['file']),
$stack['line'] $stack['line']
); );
$excerpt = sprintf('<div id="file-excerpt-%s" class="cake-code-dump" style="display:none;"><pre>', $i); $excerpt = sprintf('<div id="file-excerpt-%s" class="cake-code-dump" style="display:none;"><pre>', $i);
$excerpt .= implode("\n", Debugger::excerpt($stack['file'], $stack['line'] - 1, 2)); $excerpt .= implode("\n", Debugger::excerpt($stack['file'], $stack['line'] - 1, 2));
$excerpt .= '</pre></div> '; $excerpt .= '</pre></div> ';
else:
echo '<a href="#">[internal function]</a>';
endif; endif;
echo ' &rarr; '; echo ' &rarr; ';
if ($stack['function']): if ($stack['function']):
@ -43,13 +45,13 @@ App::uses('Debugger', 'Utility');
$args[] = Debugger::getType($arg); $args[] = Debugger::getType($arg);
$params[] = Debugger::exportVar($arg, 2); $params[] = Debugger::exportVar($arg, 2);
endforeach; endforeach;
$called = isset($stack['class']) ? $stack['class'] . $stack['type'] . $stack['function'] : $stack['function'];
printf( printf(
'<a href="#" onclick="traceToggle(event, \'trace-args-%s\')">%s%s%s(%s)</a> ', '<a href="#" onclick="traceToggle(event, \'trace-args-%s\')">%s(%s)</a> ',
$i, $i,
$stack['class'], $called,
$stack['type'],
$stack['function'],
implode(', ', $args) implode(', ', $args)
); );
$arguments = sprintf('<div id="trace-args-%s" class="cake-code-dump" style="display: none;"><pre>', $i); $arguments = sprintf('<div id="trace-args-%s" class="cake-code-dump" style="display: none;"><pre>', $i);