exception_stack_trace_nav.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. use function Cake\Core\h;
  20. ?>
  21. <a href="#" class="toggle-link toggle-vendor-frames">Toggle Vendor Stack Frames</a>
  22. <ul>
  23. <?php foreach ($exceptions as $level => $exc): ?>
  24. <?php if ($level > 0): ?>
  25. <li class="stack-previous">
  26. <span class="stack-function">Caused by</span> <?= h($exc::class) ?>
  27. </li>
  28. <?php endif; ?>
  29. <?php $stackTrace = Debugger::formatTrace($exc->getTrace(), ['format' => 'array']); ?>
  30. <?php foreach ($stackTrace as $i => $stack): ?>
  31. <?php
  32. $class = isset($stack['file']) && str_contains($stack['file'], APP) ? 'vendor-frame' : 'app-frame';
  33. $class .= $i == 0 ? ' active' : '';
  34. ?>
  35. <li class="stack-frame <?= $class ?>">
  36. <a href="#" data-target="stack-frame-<?= $i ?>">
  37. <?php if (isset($stack['class'])): ?>
  38. <span class="stack-function"><?= h($stack['class'] . $stack['type'] . $stack['function']) ?></span>
  39. <?php elseif (isset($stack['function'])): ?>
  40. <span class="stack-function"><?= h($stack['function']) ?></span>
  41. <?php endif; ?>
  42. <span class="stack-file">
  43. <?php if (isset($stack['file'], $stack['line'])): ?>
  44. <?= h(Debugger::trimPath($stack['file'])) ?>:<?= $stack['line'] ?>
  45. <?php else: ?>
  46. [internal function]
  47. <?php endif ?>
  48. </span>
  49. </a>
  50. </li>
  51. <?php endforeach; ?>
  52. <?php endforeach; ?>
  53. </ul>