core-bundle/src/EventListener/PrettyErrorScreenListener.php
private function renderErrorScreenByException(GetResponseForExceptionEvent $event): void
    {
        $exception = $event->getException();
        $statusCode = $this->getStatusCodeForException($exception);
        $template = null;

        $this->logException($exception);

        // Look for a template
        do {
            if ($exception instanceof \Exception) {
                $template = $this->getTemplateForException($exception);
            }
        } while (null === $template && null !== ($exception = $exception->getPrevious()));

        $this->renderTemplate($template ?: 'error', $statusCode, $event);
    }
private function renderErrorScreenByException(GetResponseForExceptionEvent $event): void
    {
        $exception = $event->getException();
        $statusCode = $this->getStatusCodeForException($exception);
        $template = null;

        $this->logException($exception);

        // Look for a template
        do {
            if ($exception instanceof \Exception) {
                $template = $this->getTemplateForException($exception);
            }
        } while (null === $template && null !== ($exception = $exception->getPrevious()));

        $this->renderTemplate($template ?: 'error', $statusCode, $event);
    }
Checks the exception chain for a known exception.