while ($backtrace_exception->
getPrevious()) { $backtrace_exception =
$backtrace_exception->
getPrevious();
} $backtrace =
$backtrace_exception->
getTrace();
// First trace is the error itself, already contained in the message.
// 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());