pictcode / lib / Cake / View / Elements / exception_stack_trace.ctp @ 635eef61
履歴 | 表示 | アノテート | ダウンロード (2.324 KB)
1 |
<?php |
---|---|
2 |
/** |
3 |
* Prints a stack trace for an exception |
4 |
* |
5 |
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) |
6 |
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
7 |
* |
8 |
* Licensed under The MIT License |
9 |
* For full copyright and license information, please see the LICENSE.txt |
10 |
* Redistributions of files must retain the above copyright notice. |
11 |
* |
12 |
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
13 |
* @link http://cakephp.org CakePHP(tm) Project |
14 |
* @package Cake.View.Elements |
15 |
* @since CakePHP(tm) v 1.3 |
16 |
* @license http://www.opensource.org/licenses/mit-license.php MIT License |
17 |
*/ |
18 |
|
19 |
App::uses('Debugger', 'Utility'); |
20 |
|
21 |
?> |
22 |
<h3>Stack Trace</h3> |
23 |
<ul class="cake-stack-trace"> |
24 |
<?php foreach ($error->getTrace() as $i => $stack): ?> |
25 |
<li><?php |
26 |
$excerpt = $arguments = ''; |
27 |
$params = array(); |
28 |
|
29 |
if (isset($stack['file']) && isset($stack['line'])): |
30 |
printf( |
31 |
'<a href="#" onclick="traceToggle(event, \'file-excerpt-%s\')">%s line %s</a>', |
32 |
$i, |
33 |
Debugger::trimPath($stack['file']), |
34 |
$stack['line'] |
35 |
); |
36 |
$excerpt = sprintf('<div id="file-excerpt-%s" class="cake-code-dump" style="display:none;"><pre>', $i); |
37 |
$excerpt .= implode("\n", Debugger::excerpt($stack['file'], $stack['line'] - 1, 2)); |
38 |
$excerpt .= '</pre></div> '; |
39 |
else: |
40 |
echo '<a href="#">[internal function]</a>'; |
41 |
endif; |
42 |
echo ' → '; |
43 |
if ($stack['function']): |
44 |
$args = array(); |
45 |
if (!empty($stack['args'])): |
46 |
foreach ((array)$stack['args'] as $arg): |
47 |
$args[] = Debugger::getType($arg); |
48 |
$params[] = Debugger::exportVar($arg, 4); |
49 |
endforeach; |
50 |
endif; |
51 |
|
52 |
$called = isset($stack['class']) ? $stack['class'] . $stack['type'] . $stack['function'] : $stack['function']; |
53 |
|
54 |
printf( |
55 |
'<a href="#" onclick="traceToggle(event, \'trace-args-%s\')">%s(%s)</a> ', |
56 |
$i, |
57 |
$called, |
58 |
h(implode(', ', $args)) |
59 |
); |
60 |
$arguments = sprintf('<div id="trace-args-%s" class="cake-code-dump" style="display: none;"><pre>', $i); |
61 |
$arguments .= h(implode("\n", $params)); |
62 |
$arguments .= '</pre></div>'; |
63 |
endif; |
64 |
echo $excerpt; |
65 |
echo $arguments; |
66 |
?></li> |
67 |
<?php endforeach; ?> |
68 |
</ul> |
69 |
<script type="text/javascript"> |
70 |
function traceToggle(event, id) { |
71 |
var el = document.getElementById(id); |
72 |
el.style.display = (el.style.display === 'block') ? 'none' : 'block'; |
73 |
event.preventDefault(); |
74 |
return false; |
75 |
} |
76 |
</script> |