14use UnexpectedValueException;
38 case 'application/json':
43 case 'application/xml':
51 throw new UnexpectedValueException(
'Cannot render unknown content type ' .
$contentType);
56 $body =
new Body(fopen(
'php://temp',
'r+'));
74 $title =
'Slim Application Error';
76 if ($this->displayErrorDetails) {
77 $html =
'<p>The application could not run because of the following error:</p>';
78 $html .=
'<h2>Details</h2>';
82 $html .=
'<h2>Previous error</h2>';
86 $html =
'<p>A website error has occurred. Sorry for the temporary inconvenience.</p>';
90 "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" .
91 "<title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana," .
92 "sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{" .
93 "display:inline-block;width:65px;}</style></head><body><h1>%s</h1>%s</body></html>",
125 if (($line =
$error->getLine())) {
126 $html .=
sprintf(
'<div><strong>Line:</strong> %s</div>', $line);
129 if (($trace =
$error->getTraceAsString())) {
130 $html .=
'<h2>Trace</h2>';
131 $html .=
sprintf(
'<pre>%s</pre>', htmlentities($trace));
147 'message' =>
'Slim Application Error',
150 if ($this->displayErrorDetails) {
155 'type' => get_class(
$error),
156 'code' =>
$error->getCode(),
157 'message' =>
$error->getMessage(),
158 'file' =>
$error->getFile(),
159 'line' =>
$error->getLine(),
160 'trace' => explode(
"\n",
$error->getTraceAsString()),
165 return json_encode($json, JSON_PRETTY_PRINT);
177 $xml =
"<error>\n <message>Slim Application Error</message>\n";
178 if ($this->displayErrorDetails) {
180 $xml .=
" <error>\n";
181 $xml .=
" <type>" . get_class(
$error) .
"</type>\n";
182 $xml .=
" <code>" .
$error->getCode() .
"</code>\n";
184 $xml .=
" <file>" .
$error->getFile() .
"</file>\n";
185 $xml .=
" <line>" .
$error->getLine() .
"</line>\n";
187 $xml .=
" </error>\n";
203 return sprintf(
'<![CDATA[%s]]>', str_replace(
']]>',
']]]]><![CDATA[>', $content));
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Abstract Slim application error handler.
writeToErrorLog($throwable)
Write to the error log if displayErrorDetails is false.
determineContentType(ServerRequestInterface $request)
Determine which content type we know about is wanted using Accept header.
Default Slim application error handler for PHP 7+ Throwables.
__invoke(ServerRequestInterface $request, ResponseInterface $response, \Throwable $error)
Invoke error handler.
renderHtmlError(\Throwable $error)
Render error as HTML.
renderHtmlErrorMessage(\Throwable $error)
Render HTML error page.
renderJsonErrorMessage(\Throwable $error)
Render JSON error.
renderXmlErrorMessage(\Throwable $error)
Render XML error.
createCdataSection($content)
Returns a CDATA section with the given content.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
Representation of an outgoing, server-side response.
Representation of an incoming, server-side HTTP request.
catch(Exception $e) $message
if( $path[strlen( $path) - 1]==='/') if(is_dir($path)) if(!file_exists( $path)) if(preg_match('#\.php$#D', $path)) $contentType
Slim Framework (https://slimframework.com)
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file