diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 03594fe..0b31f4a 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -64,6 +64,24 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
       require_once __DIR__ . '/common.inc';
     }
 
+    // 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',
@@ -178,15 +196,6 @@ function error_displayable($error = NULL) {
  *   TRUE if the error is fatal.
  */
 function _drupal_log_error($error, $fatal = FALSE) {
-  // Initialize a maintenance theme if the bootstrap was not complete.
-  // Do it early because drupal_set_message() triggers a drupal_theme_initialize().
-  if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
-    unset($GLOBALS['theme']);
-    if (!defined('MAINTENANCE_MODE')) {
-      define('MAINTENANCE_MODE', 'error');
-    }
-    drupal_maintenance_theme();
-  }
 
   // Backtrace array is not a valid replacement value for t().
   $backtrace = $error['backtrace'];
@@ -270,22 +279,6 @@ function _drupal_log_error($error, $fatal = FALSE) {
       }
       drupal_set_message($message, $class, TRUE);
     }
-
-    if ($fatal) {
-      // Should not translate the string to avoid errors producing more errors.
-      drupal_set_title('Error');
-      // 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.
-      $output = theme('maintenance_page', array('content' => 'The website has encountered an error. Please try again later.'));
-
-      $response = new Response($output, 500);
-      if ($fatal) {
-        $response->setStatusCode(500, '500 Service unavailable (with message)');
-      }
-
-      return $response;
-    }
   }
 }
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/ErrorHandlerTest.php b/core/modules/system/lib/Drupal/system/Tests/System/ErrorHandlerTest.php
index 7d20be9..83b9ce0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/ErrorHandlerTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/ErrorHandlerTest.php
@@ -91,6 +91,15 @@ 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.');
+    $this->verbose($this->content);
+  }
+
+  /**
    * Test the exception handler.
    */
   function testExceptionHandler() {
diff --git a/core/modules/system/tests/modules/error_test/error_test.module b/core/modules/system/tests/modules/error_test/error_test.module
index b3d9bbc..a5e52a7 100644
--- a/core/modules/system/tests/modules/error_test/error_test.module
+++ b/core/modules/system/tests/modules/error_test/error_test.module
@@ -1 +1,5 @@
 <?php
+
+function error_test_wrong_class(A $a) {
+  return "A";
+}
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 63e7707..9047d83 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
@@ -5,6 +5,13 @@ error_test.generate_warnings:
   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/modules/error_test/lib/Drupal/error_test/Controller/ErrorTestController.php b/core/modules/system/tests/modules/error_test/lib/Drupal/error_test/Controller/ErrorTestController.php
index 052bd5a..d5b1510 100644
--- a/core/modules/system/tests/modules/error_test/lib/Drupal/error_test/Controller/ErrorTestController.php
+++ b/core/modules/system/tests/modules/error_test/lib/Drupal/error_test/Controller/ErrorTestController.php
@@ -7,6 +7,7 @@
 namespace Drupal\error_test\Controller;
 
 use Drupal\Core\Controller\ControllerBase;
+use Symfony\Component\HttpFoundation\Response;
 
 /**
  * Controller routines for error_test routes.
@@ -30,6 +31,22 @@ public function generateWarnings($collect_errors = FALSE) {
   }
 
   /**
+   * Generates a recoverable error and tries to handle it.
+   */
+  public function generateRecoverableError() {
+    try {
+      $b = "Hello";
+      error_test_wrong_class($b);
+      return new Response('Type hint mismatch did not generate an exception', 500);
+    } catch (\ErrorException $e) {
+      return new Response('Type hint mismatch generated an ErrorException', 200);
+    }
+    catch (\Exception $e) {
+      return new Response('Type hint mismatch generated the wrong exception', 500);
+    }
+  }
+
+  /**
    * Trigger an exception to test the exception handler.
    */
   public function triggerException() {
