// While the second trace is the error source and also contained in the
// message, the message doesn't contain argument values, so we output it
// once more in the backtrace.
array_shift($backtrace);
// Generate a backtrace containing only scalar argument values.
$error['@backtrace'
] = Error::
formatBacktrace($backtrace);
$message =
new FormattableMarkup(Error::DEFAULT_ERROR_MESSAGE . ' <pre class="backtrace">@backtrace</pre>',
$error);
} } $content_type =
$event->
getRequest()->
getRequestFormat() == 'html' ? 'text/html' : 'text/plain';
$content =
$this->
t('The website encountered an unexpected error. Please try again later.'
);
$content .=
$message ? '<br><br>' .
$message : '';
$response =
new Response($content, 500,
['Content-Type' =>
$content_type]);
if ($exception instanceof HttpExceptionInterface
) { $response->
setStatusCode($exception->
getStatusCode());
$response->headers->
add($exception->
getHeaders());
} else { $response->
setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR, '500 Service unavailable (with message)'
);
}