diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php
index 0133cf17254b5aefdcdc8e3c2bbfb514d040f9ef..a62d93a078f4cdfcdc53ea8d8bef0286fbf48bf6 100644
--- a/core/lib/Drupal/Core/Routing/UrlGenerator.php
+++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php
@@ -12,6 +12,7 @@
 use Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface;
 use Symfony\Component\Routing\Exception\InvalidParameterException;
 use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
+use Symfony\Component\Routing\Exception\RouteNotFoundException;
 
 /**
  * Generates URLs from route names and parameters.
@@ -447,8 +448,11 @@ protected function processRoute(string $name, SymfonyRoute $route, array &$param
    * @see \Drupal\Core\Routing\RouteProviderInterface
    */
   protected function getRoute(string $name) {
-    $route = clone $this->provider->getRouteByName($name);
-    return $route;
+    $route = $this->provider->getRouteByName($name);
+    if ($route) {
+      return clone $route;
+    }
+    throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
   }
 
 }