You are here

public function ParamConversionEnhancer::onException in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php \Drupal\Core\Routing\Enhancer\ParamConversionEnhancer::onException()
  2. 9 core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php \Drupal\Core\Routing\Enhancer\ParamConversionEnhancer::onException()

Catches failed parameter conversions and throw a 404 instead.

Parameters

\Symfony\Component\HttpKernel\Event\ExceptionEvent $event: The event.

File

core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php, line 79

Class

ParamConversionEnhancer
Provides a route enhancer that handles parameter conversion.

Namespace

Drupal\Core\Routing\Enhancer

Code

public function onException(ExceptionEvent $event) {
  $exception = $event
    ->getThrowable();
  if ($exception instanceof ParamNotConvertedException) {
    $event
      ->setThrowable(new NotFoundHttpException($exception
      ->getMessage(), $exception));
  }
}