diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 3f36895..3ee8cc5 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -63,6 +63,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',
@@ -117,6 +135,7 @@ function error_displayable($error = NULL) {
  *   TRUE if the error is fatal.
  */
 function _drupal_log_error($error, $fatal = FALSE) {
+
   $is_installer = drupal_installation_attempted();
 
   // Backtrace array is not a valid replacement value for t().
@@ -225,6 +244,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
       }
     }
 
+
     if ($fatal) {
       // We fallback to a maintenance page at this point, because the page generation
       // itself can generate errors.
@@ -257,6 +277,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
         print $message;
       }
     }
+
   }
 }
 
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";
+}
