2 namespace TYPO3\CMS\Core\Error;
31 set_exception_handler(array($this,
'handleException'));
43 $filePathAndName = $exception->getFile();
44 $exceptionCodeNumber = $exception->getCode() > 0 ?
'#' . $exception->getCode() .
': ' :
'';
45 $moreInformationLink = $exceptionCodeNumber !==
''
46 ?
'(<a href="' . TYPO3_URL_EXCEPTION .
'debug/' . $exception->getCode() .
'" target="_blank">More information</a>)'
51 $xmlPrologue =
'<?xml version="1.0" encoding="utf-8"?>';
53 $docType =
'<!DOCTYPE html
54 PUBLIC "-//W3C//DTD XHTML 1.1//EN"
55 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
57 $browserInfo = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo(
61 if ($browserInfo[
'browser'] ===
'msie' && $browserInfo[
'version'] < 7) {
62 $headerStart = $docType . LF . $xmlPrologue;
64 $headerStart = $xmlPrologue . LF . $docType;
67 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
69 <title>TYPO3 Exception</title>
70 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
71 <style type="text/css">
79 background-color: #D0D0D0;
88 background-color: #B9B9B9;
89 outline: 1px solid #515151;
91 font-family: Arial, Helvetica, sans-serif;
96 <div style="width: 100%; background-color: #515151; color: white; padding: 2px; margin: 0 0 6px 0;">Uncaught TYPO3 Exception</div>
97 <div style="width: 100%; padding: 2px; margin: 0 0 6px 0;">
98 <strong style="color: #BE0027;">' . $exceptionCodeNumber . htmlspecialchars($exception->getMessage()) .
'</strong> ' . $moreInformationLink .
'<br />
100 <span class="ExceptionProperty">' . get_class($exception) .
'</span> thrown in file<br />
101 <span class="ExceptionProperty">' . htmlspecialchars($filePathAndName) .
'</span> in line
102 <span class="ExceptionProperty">' . $exception->getLine() .
'</span>.<br />
104 ' . $backtraceCode .
'
120 $filePathAndName = $exception->getFile();
121 $exceptionCodeNumber = $exception->getCode() > 0 ?
'#' . $exception->getCode() .
': ' :
'';
124 Uncaught TYPO3 Exception ' . $exceptionCodeNumber . $exception->getMessage() . LF;
125 echo
'thrown in file ' . $filePathAndName . LF;
126 echo
'in line ' . $exception->getLine() .
'
141 if (!empty($trace)) {
142 foreach ($trace as $index => $step) {
143 $class = isset($step[
'class']) ? $step[
'class'] .
'<span style="color:white;">::</span>' :
'';
145 if (isset($step[
'args']) && is_array($step[
'args'])) {
146 foreach ($step[
'args'] as $argument) {
147 $arguments .= (string)$arguments ===
'' ?
'' :
'<span style="color:white;">,</span> ';
148 if (is_object($argument)) {
149 $arguments .=
'<span style="color:#FF8700;"><em>' . get_class($argument) .
'</em></span>';
150 }
elseif (is_string($argument)) {
151 $preparedArgument = strlen($argument) < 100
153 : substr($argument, 0, 50) .
'#tripleDot#' . substr($argument, -50);
154 $preparedArgument = str_replace(
159 '<span style="color:white;">…</span>',
160 '<span style="color:white;">↵</span>'
162 htmlspecialchars($preparedArgument)
164 $arguments .=
'"<span style="color:#FF8700;" title="' . htmlspecialchars($argument) .
'">'
165 . $preparedArgument .
'</span>"';
166 }
elseif (is_numeric($argument)) {
167 $arguments .=
'<span style="color:#FF8700;">' . (string)$argument .
'</span>';
169 $arguments .=
'<span style="color:#FF8700;"><em>' . gettype($argument) .
'</em></span>';
173 $backtraceCode .=
'<pre style="color:#69A550; background-color: #414141; padding: 4px 2px 4px 2px;">';
174 $backtraceCode .=
'<span style="color:white;">' . (count($trace) - $index) .
'</span> ' . $class
175 . $step[
'function'] .
'<span style="color:white;">(' . $arguments .
')</span>';
176 $backtraceCode .=
'</pre>';
177 if (isset($step[
'file'])) {
178 $backtraceCode .= $this->
getCodeSnippet($step[
'file'], $step[
'line']) .
'<br />';
182 return $backtraceCode;
194 $codeSnippet =
'<br />';
195 if (@file_exists($filePathAndName)) {
196 $phpFile = @file($filePathAndName);
197 if (is_array($phpFile)) {
198 $startLine = $lineNumber > 2 ? $lineNumber - 2 : 1;
199 $phpFileCount = count($phpFile);
200 $endLine = $lineNumber < $phpFileCount - 2 ? $lineNumber + 3 : $phpFileCount + 1;
201 if ($endLine > $startLine) {
202 $codeSnippet =
'<br /><span style="font-size:10px;">' . $filePathAndName .
':</span><br /><pre>';
203 for ($line = $startLine; $line < $endLine; $line++) {
204 $codeLine = str_replace(TAB,
' ', $phpFile[$line - 1]);
205 if ($line === $lineNumber) {
206 $codeSnippet .=
'</pre><pre style="background-color: #F1F1F1; color: black;">';
208 $codeSnippet .= sprintf(
'%05d', $line) .
': ' . $codeLine;
209 if ($line === $lineNumber) {
210 $codeSnippet .=
'</pre><pre>';
213 $codeSnippet .=
'</pre>';