$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)'
);
} $event->
setResponse($response);
} /**
* Handles all 4xx errors that aren't caught in other exception subscribers.
*
* For example, we catch 406s and 403s generated when handling unsupported
* formats.
*
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/