_drupal_get_error_level

_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.

File

core/includes/errors.inc, line 301
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 (drupal_installation_attempted()) {
    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 = isset($GLOBALS['config']['system.logging']['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;
}
doc_Drupal
2016-10-29 09:57:09
Comments
Leave a Comment

Please login to continue.