diff --git a/core/lib/Drupal/Core/Template/Loader/ThemeRegistryLoader.php b/core/lib/Drupal/Core/Template/Loader/ThemeRegistryLoader.php
index fe1ae25..4d6ba8d 100644
--- a/core/lib/Drupal/Core/Template/Loader/ThemeRegistryLoader.php
+++ b/core/lib/Drupal/Core/Template/Loader/ThemeRegistryLoader.php
@@ -38,6 +38,8 @@ public function __construct(Registry $theme_registry) {
    *
    * @param string $name
    *   The name of the template to load.
+   * @param bool $throw
+   *   Whether to throw an exception when an error occurs.
    *
    * @return string
    *   The path to the template.
@@ -45,7 +47,7 @@ public function __construct(Registry $theme_registry) {
    * @throws \Twig_Error_Loader
    *   Thrown if a template matching $name cannot be found.
    */
-  protected function findTemplate($name) {
+  protected function findTemplate($name, $throw = TRUE) {
     // Allow for loading based on the Drupal theme registry.
     $hook = str_replace('.html.twig', '', strtr($name, '-', '_'));
     $theme_registry = $this->themeRegistry->getRuntime();
@@ -63,7 +65,9 @@ protected function findTemplate($name) {
       }
     }
 
-    throw new \Twig_Error_Loader(sprintf('Unable to find template "%s" in the Drupal theme registry.', $name));
+    if ($throw) {
+      throw new \Twig_Error_Loader(sprintf('Unable to find template "%s" in the Drupal theme registry.', $name));
+    }
   }
 
 }
