dev_error.php 9.5 KB

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