code: public function onKernelException(GetResponseForExceptionEvent $event): void
      {
          $exception = $event->getException();
  
          if ($exception->getPrevious() instanceof ResourceNotFoundException && !$this->hasRootPages()) {
              $exception = new NoRootPageFoundException('No root page found', 0, $exception);
          }
  
          $class = $this->getTargetClass($exception);
  
          if (null === $class) {
              return;
          }
  
          if (null !== ($httpException = $this->convertToHttpException($exception, $class))) {
              $event->setException($httpException);
          }
      }
docs: Maps known exceptions to HTTP exceptions.