You are here

protected function FinalExceptionSubscriber::simplifyFileInError in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/EventSubscriber/FinalExceptionSubscriber.php \Drupal\Core\EventSubscriber\FinalExceptionSubscriber::simplifyFileInError()

Attempts to reduce error verbosity in the error message's file path.

Attempts to reduce verbosity by removing DRUPAL_ROOT from the file path in the message. This does not happen for (false) security.

Parameters

$error: Optional error to examine for ERROR_REPORTING_DISPLAY_SOME.

Return value

The updated $error.

1 call to FinalExceptionSubscriber::simplifyFileInError()
FinalExceptionSubscriber::onException in core/lib/Drupal/Core/EventSubscriber/FinalExceptionSubscriber.php
Handles exceptions for this subscriber.
1 method overrides FinalExceptionSubscriber::simplifyFileInError()
TestDefaultExceptionSubscriber::simplifyFileInError in core/tests/Drupal/Tests/Core/EventSubscriber/FinalExceptionSubscriberTest.php
Attempts to reduce error verbosity in the error message's file path.

File

core/lib/Drupal/Core/EventSubscriber/FinalExceptionSubscriber.php, line 186

Class

FinalExceptionSubscriber
Last-chance handler for exceptions: the final exception subscriber.

Namespace

Drupal\Core\EventSubscriber

Code

protected function simplifyFileInError($error) {

  // Attempt to reduce verbosity by removing DRUPAL_ROOT from the file path
  // in the message. This does not happen for (false) security.
  $root_length = strlen(DRUPAL_ROOT);
  if (substr($error['%file'], 0, $root_length) == DRUPAL_ROOT) {
    $error['%file'] = substr($error['%file'], $root_length + 1);
  }
  return $error;
}