exception_stack_trace_nav.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. * @var array $trace
  15. * @var \Throwable $error
  16. * @var array<\Throwable> $exceptions
  17. */
  18. use Cake\Error\Debugger;
  19. ?>
  20. <a href="#" class="toggle-link toggle-vendor-frames">Toggle Vendor Stack Frames</a>
  21. <?php foreach ($exceptions as $level => $exc): ?>
  22. <?php if ($level > 0): ?>
  23. <li class="stack-previous">
  24. <span class="stack-function">Caused by</span> <?= h(get_class($exc)) ?>
  25. </li>
  26. <?php endif; ?>
  27. <?php $stackTrace = Debugger::formatTrace($exc->getTrace(), ['format' => 'array']); ?>
  28. <?php foreach ($stackTrace as $i => $stack): ?>
  29. <?php
  30. $class = isset($stack['file']) && str_contains($stack['file'], APP) ? 'vendor-frame' : 'app-frame';
  31. $class .= $i == 0 ? ' active' : '';
  32. ?>
  33. <li class="stack-frame <?= $class ?>">
  34. <a href="#" data-target="stack-frame-<?= $i ?>">
  35. <?php if (isset($stack['class'])): ?>
  36. <span class="stack-function"><?= h($stack['class'] . $stack['type'] . $stack['function']) ?></span>
  37. <?php elseif (isset($stack['function'])): ?>
  38. <span class="stack-function"><?= h($stack['function']) ?></span>
  39. <?php endif; ?>
  40. <span class="stack-file">
  41. <?php if (isset($stack['file'], $stack['line'])): ?>
  42. <?= h(Debugger::trimPath($stack['file'])) ?>:<?= $stack['line'] ?>
  43. <?php else: ?>
  44. [internal function]
  45. <?php endif ?>
  46. </span>
  47. </a>
  48. </li>
  49. <?php endforeach; ?>
  50. <?php endforeach; ?>
  51. </ul>