dev_error.php 11 KB

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