modules/acm_exception/src/EventSubscriber/RouteExceptionSubscriber.php
public function onException(GetResponseForExceptionEvent $event) {
    $exception = $event->getException();
    if (!($exception instanceof RouteException) || PHP_SAPI === 'cli') {
      return;
    }

    $handler = \Drupal::service('acm_exception.route_exception_handler');
    $redirect = $handler->getRedirect($exception);
    $event->setResponse(RedirectResponse::create($redirect, 302));
  }
public function onException(GetResponseForExceptionEvent $event) {
    $exception = $event->getException();
    if (!($exception instanceof RouteException) || PHP_SAPI === 'cli') {
      return;
    }

    $handler = \Drupal::service('acm_exception.route_exception_handler');
    $redirect = $handler->getRedirect($exception);
    $event->setResponse(RedirectResponse::create($redirect, 302));
  }
public function onException ( GetResponseForExceptionEvent $ event ) { $ exception = $ event -> getException ( ) ; if ( ! ( $ exception instanceof RouteException ) || PHP_SAPI === 'cli' ) { return ; } $ handler = \ Drupal :: service ( 'acm_exception.route_exception_handler' ) ; $ redirect = $ handler -> getRedirect ( $ exception ) ; $ event -> setResponse ( RedirectResponse :: create ( $ redirect , 302 ) ) ; }
Catch all uncaught RouteException exceptions.

@param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
The event to process.
Catch all uncaught RouteException exceptions .