function _fp_error_handler

7.x misc.inc _fp_error_handler($error_level, $message, $filename, $line, $context = array())
6.x misc.inc _fp_error_handler($error_level, $message, $filename, $line, $context = array())
5.x misc.inc _fp_error_handler($error_level, $message, $filename, $line, $context = array())

This is our custom error handler, which will intercept PHP warnings, notices, etc, and let us display them, log them, etc.

See https://www.php.net/manual/en/function.set-error-handler.php

1 string reference to '_fp_error_handler'
bootstrap.inc in ./bootstrap.inc
This file should be included by every public-facing page of FlightPath. It will include all the classes, as well as settings and function files, and modules.

File

includes/misc.inc, line 17
This file contains misc functions for FlightPath

Code

function _fp_error_handler($error_level, $message, $filename, $line, $context = array()) {
  global $user;

  if (0 === error_reporting()) {
    return false;
  } // suppressed with @-operator

  $err_name = _fp_map_php_error_code($error_level);

  if (stristr($err_name, 'notice')) {
    return FALSE; // don't care about Notices. 
  }

  // fpm() only displays for privileged users
  fpm($err_name . ": $message<br>... ($line) $filename");

  if (@$user->id !== '1' && @$user->id !== 1) {
    // We are NOT the admin user.

    // Should we email someone, as with mysql errors?
    $tomail = trim(variable_get("notify_php_error_email_address", ""));
    if ($tomail != "") {

      $hostname = php_uname('n') . ' - ' . $GLOBALS ['fp_system_settings']['base_url'];

      $msg = "";
      $msg .= "SERVER:   $hostname \n";
      $msg .= "DATE:     " . format_date() . "\n";
      $msg .= "SEVERITY: $err_name \n";
      $msg .= "--------------------------\n\n";
      $msg .= "$err_name: $message \n\n";
      $msg .= "... ($line) $filename";

      fp_mail($tomail, "PHP Error in FlightPath", $msg);

    }

  }

}