dev_error.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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 \Cake\Core\Exception\CakeException $error
  15. */
  16. use Cake\Error\Debugger;
  17. use function Cake\Core\h;
  18. ?>
  19. <!DOCTYPE html>
  20. <html>
  21. <head>
  22. <?= $this->Html->charset() ?>
  23. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  24. <title>
  25. Error: <?= h($this->fetch('title')) ?>
  26. </title>
  27. <?= $this->Html->meta('icon') ?>
  28. <style>
  29. * {
  30. box-sizing: border-box;
  31. }
  32. :root {
  33. --typeface: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
  34. --typeface-mono: consolas, monospace;
  35. --border-radius: 5px;
  36. --layout-padding: 30px;
  37. --layout-vertical-gap: 20px;
  38. --color-vendor-frame: #7c7c7c;
  39. --breakpoint-tablet: 810px;
  40. }
  41. /* Smaller viewport variations */
  42. @media (max-width: 810px) {
  43. :root {
  44. --layout-padding: 20px;
  45. }
  46. }
  47. body {
  48. font-family: var(--typeface);
  49. color: #404041;
  50. background: #F5F7FA;
  51. font-size: 14px;
  52. letter-spacing: .01em;
  53. line-height: 1.6;
  54. padding: 0 0 40px;
  55. margin: 0;
  56. height: 100%;
  57. }
  58. header {
  59. flex: 1;
  60. background-color: #D33C47;
  61. color: #ffffff;
  62. padding: var(--layout-padding);
  63. }
  64. .header-title {
  65. display: flex;
  66. align-items: center;
  67. font-size: 30px;
  68. margin: 0;
  69. }
  70. .header-title a {
  71. font-size: 18px;
  72. cursor: pointer;
  73. margin-left: 10px;
  74. user-select: none;
  75. }
  76. .header-title code {
  77. margin: 0 10px;
  78. }
  79. .header-description {
  80. display: block;
  81. font-size: 18px;
  82. line-height: 1.2;
  83. margin-bottom: var(--layout-vertical-gap);
  84. }
  85. .header-type {
  86. display: block;
  87. font-size: 16px;
  88. }
  89. .header-help a {
  90. color: #fff;
  91. }
  92. .error-content {
  93. padding: var(--layout-padding);
  94. }
  95. .code-dump,
  96. pre {
  97. background: #fff;
  98. border-radius: var(--border-radius);
  99. padding: 5px;
  100. white-space: pre-wrap;
  101. margin: 0;
  102. }
  103. .error,
  104. .error-subheading {
  105. border-radius: var(--border-radius);
  106. font-size: 18px;
  107. margin-top: 0;
  108. padding: var(--layout-vertical-gap) 16px;
  109. }
  110. .error-subheading {
  111. color: #fff;
  112. background-color: #319795;
  113. }
  114. .error-subheading strong {
  115. color: #fff;
  116. background-color: #4fd1c5;
  117. border-radius: 9999px;
  118. padding: 4px 12px;
  119. margin-right: 8px;
  120. }
  121. .error {
  122. color: #fff;
  123. background: #2779BD;
  124. }
  125. .error strong {
  126. color: #fff;
  127. background-color: #6CB2EB;
  128. border-radius: 9999px;
  129. padding: 4px 12px;
  130. margin-right: 8px;
  131. }
  132. .stack-trace {
  133. list-style: none;
  134. margin: 0;
  135. padding: 0;
  136. }
  137. /* Previous exception blocks */
  138. .stack-exception-header {
  139. margin: 36px 0 12px 8px;
  140. }
  141. .stack-exception-caused {
  142. font-size: 1.6em;
  143. display: block;
  144. margin-bottom: var(--layout-vertical-gap);
  145. }
  146. .stack-exception-type {
  147. display: block;
  148. font-family: var(--typeface-mono);
  149. }
  150. .stack-exception-message {
  151. margin-bottom: 10px;
  152. font-size: 1.2em;
  153. font-weight: bold;
  154. }
  155. .stack-frames {
  156. list-style: none;
  157. padding: 0;
  158. margin: 0;
  159. border-radius: var(--border-radius);
  160. }
  161. .stack-frame {
  162. padding: 10px;
  163. background: #eaeaea;
  164. padding: 10px;
  165. border-bottom: 2px solid #f5f7fa;
  166. overflow: hidden;
  167. }
  168. .vendor-frame {
  169. background: #f1f1f1;
  170. }
  171. .stack-frame:first-child {
  172. border-radius: var(--border-radius) var(--border-radius) 0 0;
  173. }
  174. .stack-frame:last-child {
  175. border-radius: 0 0 var(--border-radius) var(--border-radius);
  176. border-bottom: none;
  177. margin-bottom: 0;
  178. }
  179. .stack-frame a {
  180. color: #212121;
  181. text-decoration: none;
  182. }
  183. .stack-frame.active {
  184. background: #F5F7FA;
  185. }
  186. .stack-frame a:hover {
  187. text-decoration: underline;
  188. }
  189. /* Stack frame headers */
  190. .stack-frame-header {
  191. display: flex;
  192. align-items: center;
  193. gap: 10px;
  194. }
  195. .stack-frame-header-content {
  196. display: flex;
  197. gap: 8px;
  198. }
  199. .vendor-frame .stack-frame-header-content,
  200. .vendor-frame .stack-frame-header-content a {
  201. color: var(--color-vendor-frame);
  202. }
  203. @media (max-width: 810px) {
  204. .stack-frame-header-content {
  205. flex-direction: column;
  206. }
  207. }
  208. .stack-function,
  209. .stack-frame-file,
  210. .stack-frame-line,
  211. .stack-file {
  212. font-family: var(--typeface-mono);
  213. }
  214. .stack-file {
  215. font-size: 0.9em;
  216. white-space: nowrap;
  217. text-overflow: ellipsis;
  218. overflow: hidden;
  219. direction: rtl;
  220. }
  221. .stack-frame-file {
  222. word-break: break-all;
  223. }
  224. .stack-frame-label {
  225. font-family: var(--typeface);
  226. font-weight: normal;
  227. margin: 0 5px 0 0;
  228. font-size: 0.9em;
  229. }
  230. .stack-function .stack-frame-label {
  231. margin: 0;
  232. }
  233. .stack-frame-edit {
  234. margin: 0 5px 0 0;
  235. }
  236. .stack-frame-toggle {
  237. cursor: pointer;
  238. color: #525252;
  239. border: 1px solid #d2d2d2;
  240. border-radius: var(--border-radius);
  241. height: 28px;
  242. width: 28px;
  243. background: #F5F7FA;
  244. line-height: 1.5;
  245. }
  246. .stack-frame-toggle.active {
  247. transform: rotate(180deg);
  248. }
  249. .stack-frame-header .stack-frame-toggle {
  250. opacity: 0.7;
  251. }
  252. .stack-frame-args {
  253. display: block;
  254. margin: 10px 0 0 0;
  255. }
  256. .stack-frame-args:hover {
  257. color: #D33C47;
  258. }
  259. .stack-args h4 {
  260. margin-top: 0;
  261. }
  262. /* Suggestion and help context */
  263. .error-suggestion {
  264. margin-bottom: var(--layout-vertical-gap);
  265. }
  266. /* Code excerpts */
  267. .code-excerpt {
  268. width: 100%;
  269. margin: 10px 0 0 0;
  270. background: #fefefe;
  271. }
  272. .code-highlight {
  273. display: block;
  274. background: #fff59d;
  275. padding-left: 4px;
  276. }
  277. .excerpt-line {
  278. padding: 0;
  279. }
  280. /* php 8.3 adds pre around highlighted code */
  281. .code-highlight > pre,
  282. .excerpt-line > pre {
  283. padding: 0;
  284. background: none;
  285. }
  286. .excerpt-line > code {
  287. padding-left: 4px;
  288. }
  289. .excerpt-number {
  290. background: #f6f6f6;
  291. width: 50px;
  292. text-align: right;
  293. color: #666;
  294. border-right: 1px solid #ddd;
  295. padding: 2px 4px;
  296. }
  297. .excerpt-number:after {
  298. content: attr(data-number);
  299. }
  300. table {
  301. text-align: left;
  302. }
  303. th, td {
  304. padding: 4px;
  305. }
  306. th {
  307. border-bottom: 1px solid #ccc;
  308. }
  309. .cake-debug {
  310. margin-top: 10px;
  311. }
  312. </style>
  313. <?php require CAKE . 'Error/Debug/dumpHeader.html'; ?>
  314. </head>
  315. <body>
  316. <header>
  317. <?php
  318. $title = explode("\n", trim($this->fetch('title')));
  319. $errorTitle = array_shift($title);
  320. $errorDescription = implode("\n", $title);
  321. ?>
  322. <h1 class="header-title">
  323. <span><?= Debugger::formatHtmlMessage($errorTitle) ?></span>
  324. <a>&#128203</a>
  325. </h1>
  326. <?php if (strlen($errorDescription)) : ?>
  327. <span class="header-description"><?= Debugger::formatHtmlMessage($errorDescription) ?></span>
  328. <?php endif ?>
  329. <span class="header-type"><?= $error::class ?></span>
  330. </header>
  331. <div class="error-content">
  332. <?php if ($this->fetch('subheading')): ?>
  333. <p class="error-subheading">
  334. <?= $this->fetch('subheading') ?>
  335. </p>
  336. <?php endif; ?>
  337. <?php if ($this->fetch('file')): ?>
  338. <div class="error-suggestion">
  339. <?= $this->fetch('file') ?>
  340. </div>
  341. <?php endif; ?>
  342. <?= $this->element('dev_error_stacktrace'); ?>
  343. <?php if ($this->fetch('templateName')): ?>
  344. <p class="customize">
  345. If you want to customize this error message, create
  346. <em><?= 'templates' . DIRECTORY_SEPARATOR . 'Error' . DIRECTORY_SEPARATOR . $this->fetch('templateName') ?></em>
  347. </p>
  348. <?php endif; ?>
  349. </div>
  350. <script type="text/javascript">
  351. function bindEvent(selector, eventName, listener) {
  352. var els = document.querySelectorAll(selector);
  353. for (var i = 0, len = els.length; i < len; i++) {
  354. els[i].addEventListener(eventName, listener, false);
  355. }
  356. }
  357. function toggleElement(el) {
  358. if (el.style.display === 'none') {
  359. el.style.display = 'block';
  360. } else {
  361. el.style.display = 'none';
  362. }
  363. }
  364. function each(els, cb) {
  365. var i, len;
  366. for (i = 0, len = els.length; i < len; i++) {
  367. cb(els[i], i);
  368. }
  369. }
  370. window.addEventListener('load', function() {
  371. bindEvent('.stack-frame-args', 'click', function(event) {
  372. var target = this.dataset['target'];
  373. var el = document.getElementById(target);
  374. toggleElement(el);
  375. event.preventDefault();
  376. });
  377. var details = document.querySelectorAll('.stack-details');
  378. var frames = document.querySelectorAll('.stack-frame');
  379. bindEvent('.stack-frame-toggle', 'click', function(event) {
  380. this.classList.toggle('active');
  381. var frameId = this.dataset.frameId;
  382. var frame = document.getElementById('stack-frame-details-' + frameId);
  383. toggleElement(frame);
  384. event.preventDefault();
  385. });
  386. bindEvent('.header-title a', 'click', function(event) {
  387. event.preventDefault();
  388. var text = '';
  389. each(this.parentNode.childNodes, function(el) {
  390. if (el.nodeName !== 'A') {
  391. text += el.textContent.trim();
  392. }
  393. });
  394. // Use execCommand(copy) as it has the widest support.
  395. var textArea = document.createElement("textarea");
  396. textArea.value = text;
  397. document.body.appendChild(textArea);
  398. textArea.focus();
  399. textArea.select();
  400. var el = this;
  401. try {
  402. document.execCommand('copy');
  403. // Show a success icon and then revert
  404. var original = el.innerText;
  405. el.innerText = '\ud83c\udf70';
  406. setTimeout(function () {
  407. el.innerText = original;
  408. }, 1000);
  409. } catch (err) {
  410. alert('Unable to update clipboard ' + err);
  411. }
  412. document.body.removeChild(textArea);
  413. this.parentNode.parentNode.scrollIntoView(true);
  414. });
  415. });
  416. </script>
  417. </body>
  418. </html>