diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 06753fd..aaded0b 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -62,6 +62,24 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
     $backtrace = debug_backtrace();
     $caller = Error::getLastCaller($backtrace);
 
+    // Recoverable errors are rare, but it's generally easier to deal with them
+    // in context than here. Therefore convert them to exceptions so that they
+    // can be caught and handled.  If uncaught, they become fatal but use the
+    // same pipleline as any other uncaught exception.
+    if ($error_level == E_RECOVERABLE_ERROR) {
+      // Initialize a maintenance theme if the bootstrap was not complete.
+      // Do it early because drupal_set_message() triggers a drupal_theme_initialize().
+      if (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL) {
+        unset($GLOBALS['theme']);
+        if (!defined('MAINTENANCE_MODE')) {
+          define('MAINTENANCE_MODE', 'error');
+        }
+        drupal_maintenance_theme();
+      }
+
+      throw new ErrorException($message, $error_level, 0, $filename, $line);
+    }
+
     // We treat recoverable errors as fatal.
     _drupal_log_error(array(
       '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
@@ -73,7 +91,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
       '%line' => $caller['line'],
       'severity_level' => $severity_level,
       'backtrace' => $backtrace,
-    ), $error_level == E_RECOVERABLE_ERROR);
+    ));
   }
 }
 
@@ -116,23 +134,6 @@ function error_displayable($error = NULL) {
  *   TRUE if the error is fatal.
  */
 function _drupal_log_error($error, $fatal = FALSE) {
-  $is_installer = drupal_installation_attempted();
-  // Initialize a maintenance theme if the bootstrap was not complete.
-  // Do it early because drupal_set_message() triggers a
-  // \Drupal\Core\Theme\ThemeManager::initTheme().
-  if ($fatal && \Drupal::hasService('theme.manager')) {
-    // The installer initializes a maintenance theme at the earliest possible
-    // point in time already. Do not unset that.
-    if (!$is_installer) {
-      \Drupal::theme()->resetActiveTheme();
-    }
-    if (!defined('MAINTENANCE_MODE')) {
-      define('MAINTENANCE_MODE', 'error');
-    }
-    // No-op if the active theme is set already.
-    drupal_maintenance_theme();
-  }
-
   // Backtrace array is not a valid replacement value for t().
   $backtrace = $error['backtrace'];
   unset($error['backtrace']);
@@ -227,29 +228,6 @@ function _drupal_log_error($error, $fatal = FALSE) {
         print $message;
       }
     }
-
-    if ($fatal) {
-      // We fallback to a maintenance page at this point, because the page generation
-      // itself can generate errors.
-      // Should not translate the string to avoid errors producing more errors.
-      $message = 'The website encountered an unexpected error. Please try again later.';
-      if ($is_installer) {
-        // install_display_output() prints the output and ends script execution.
-        $output = array(
-          '#title' => 'Error',
-          '#markup' => $message,
-        );
-        install_display_output($output, $GLOBALS['install_state']);
-        exit;
-      }
-
-      $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
-      $response = $bare_html_page_renderer->renderBarePage(['#markup' => $message], 'Error', 'maintenance_page');
-      $response->setStatusCode(500, '500 Service unavailable (with message)');
-      // An exception must halt script execution.
-      $response->send();
-      exit;
-    }
   }
 }
 
diff --git a/core/modules/system/src/Tests/System/ErrorHandlerTest.php b/core/modules/system/src/Tests/System/ErrorHandlerTest.php
index e985f28..74283c2 100644
--- a/core/modules/system/src/Tests/System/ErrorHandlerTest.php
+++ b/core/modules/system/src/Tests/System/ErrorHandlerTest.php
@@ -115,6 +115,14 @@ function testErrorHandler() {
   }
 
   /**
+   * Test the converting of E_RECOVERABLE_ERROR to ErrorException.
+   */
+  function testRecoverableErrors() {
+    $this->drupalGet('error-test/generate-recoverable-error');
+    $this->assertResponse(200, 'Received expected HTTP status code.');
+  }
+
+  /**
    * Test the exception handler.
    */
   function testExceptionHandler() {
diff --git a/core/modules/system/tests/modules/error_test/error_test.routing.yml b/core/modules/system/tests/modules/error_test/error_test.routing.yml
index ad96152..ad07eb4 100644
--- a/core/modules/system/tests/modules/error_test/error_test.routing.yml
+++ b/core/modules/system/tests/modules/error_test/error_test.routing.yml
@@ -12,6 +12,13 @@ error_test.generate_fatals:
   requirements:
     _access: 'TRUE'
 
+error_test.generate_recoverable_error:
+  path: '/error-test/generate-recoverable-error'
+  defaults:
+    _content: '\Drupal\error_test\Controller\ErrorTestController::generateRecoverableError'
+  requirements:
+    _access: 'TRUE'
+
 error_test.generate_warnings_with_report:
   path: '/error-test/generate-warnings-with-report'
   defaults:
diff --git a/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme b/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme
index b3d9bbc..a5e52a7 100644
--- a/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme
+++ b/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme
@@ -1 +1,5 @@
 <?php
+
+function error_test_wrong_class(A $a) {
+  return "A";
+}
