Same name and namespace in other branches
  1. 4.6.x includes/common.inc \error_handler()
  2. 4.7.x includes/common.inc \error_handler()

Log errors as defined by administrator Error levels: 0 = Log errors to database. 1 = Log errors to database and to screen.

1 string reference to 'error_handler'
_drupal_bootstrap_full in includes/common.inc

File

includes/common.inc, line 585
Common functions that many Drupal modules will need to reference.

Code

function error_handler($errno, $message, $filename, $line) {

  // If the @ error suppression operator was used, error_reporting is temporarily set to 0
  if (error_reporting() == 0) {
    return;
  }
  if ($errno & (E_ALL ^ E_NOTICE)) {
    $types = array(
      1 => 'error',
      2 => 'warning',
      4 => 'parse error',
      8 => 'notice',
      16 => 'core error',
      32 => 'core warning',
      64 => 'compile error',
      128 => 'compile warning',
      256 => 'user error',
      512 => 'user warning',
      1024 => 'user notice',
      2048 => 'strict warning',
      4096 => 'recoverable fatal error',
    );
    $entry = $types[$errno] . ': ' . $message . ' in ' . $filename . ' on line ' . $line . '.';

    // Force display of error messages in update.php
    if (variable_get('error_level', 1) == 1 || strstr($_SERVER['SCRIPT_NAME'], 'update.php')) {
      drupal_set_message($entry, 'error');
    }
    watchdog('php', t('%message in %file on line %line.', array(
      '%error' => $types[$errno],
      '%message' => $message,
      '%file' => $filename,
      '%line' => $line,
    )), WATCHDOG_ERROR);
  }
}