diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 99cab85..af8b916 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -248,7 +248,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
       // An exception must halt script execution.
       exit;
     }
-    else {
+    elseif (error_displayable($error)) {
       if (\Drupal::hasService('session')) {
         // Message display is dependent on sessions being available.
         drupal_set_message(SafeMarkup::set($message), $class, TRUE);
diff --git a/core/modules/system/src/Tests/System/ErrorHandlerTest.php b/core/modules/system/src/Tests/System/ErrorHandlerTest.php
index 8164f36..c65a67e 100644
--- a/core/modules/system/src/Tests/System/ErrorHandlerTest.php
+++ b/core/modules/system/src/Tests/System/ErrorHandlerTest.php
@@ -111,6 +111,7 @@ function testErrorHandler() {
     $this->assertNoErrorMessage($error_notice);
     $this->assertNoErrorMessage($error_warning);
     $this->assertNoErrorMessage($error_user_notice);
+    $this->assertNoRaw('class="messages messages--"', 'Did not find the messages block');
     $this->assertNoRaw('<pre class="backtrace">', 'Did not find pre element with backtrace class.');
   }
 
