Same name and namespace in other branches
  1. 8.9.x core/includes/errors.inc \_drupal_get_error_level()
  2. 9 core/includes/errors.inc \_drupal_get_error_level()

Returns the current error level.

This function should only be used to get the current error level prior to the kernel being booted or before Drupal is installed. In all other situations the following code is preferred:

\Drupal::config('system.logging')
  ->get('error_level');

Return value

string The current error level.

2 calls to _drupal_get_error_level()
error_displayable in core/includes/errors.inc
Determines whether an error should be displayed.
_drupal_log_error in core/includes/errors.inc
Logs a PHP error or exception and displays an error page in fatal cases.

File

core/includes/errors.inc, line 308
Functions for error handling.

Code

function _drupal_get_error_level() {

  // Raise the error level to maximum for the installer, so users are able to
  // file proper bug reports for installer errors. The returned value is
  // different to the one below, because the installer actually has a
  // 'config.factory' service, which reads the default 'error_level' value from
  // System module's default configuration and the default value is not verbose.
  // @see error_displayable()
  if (InstallerKernel::installationAttempted()) {
    return ERROR_REPORTING_DISPLAY_VERBOSE;
  }
  $error_level = NULL;

  // Try to get the error level configuration from database. If this fails,
  // for example if the database connection is not there, try to read it from
  // settings.php.
  try {
    $error_level = \Drupal::config('system.logging')
      ->get('error_level');
  } catch (\Exception $e) {
    $error_level = $GLOBALS['config']['system.logging']['error_level'] ?? ERROR_REPORTING_HIDE;
  }

  // If there is no container or if it has no config.factory service, we are
  // possibly in an edge-case error situation while trying to serve a regular
  // request on a public site, so use the non-verbose default value.
  return $error_level ?: ERROR_REPORTING_DISPLAY_ALL;
}