You are here

function userErrorHandler in TinyBrowser 7

1 string reference to 'userErrorHandler'
fns_tinybrowser.php in tinybrowser/fns_tinybrowser.php

File

tinybrowser/fns_tinybrowser.php, line 537

Code

function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars) {

  // timestamp for the error entry.
  $dt = date('Y-m-d H:i:s (T)');

  // define an assoc array of error string
  // in reality the only entries we should
  // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
  // E_USER_WARNING and E_USER_NOTICE.
  $errortype = array(
    E_ERROR => 'Error',
    E_WARNING => 'Warning',
    E_PARSE => 'Parsing Error',
    E_NOTICE => 'Notice',
    E_CORE_ERROR => 'Core Error',
    E_CORE_WARNING => 'Core Warning',
    E_COMPILE_ERROR => 'Compile Error',
    E_COMPILE_WARNING => 'Compile Warning',
    E_USER_ERROR => 'User Error',
    E_USER_WARNING => 'User Warning',
    E_USER_NOTICE => 'User Notice',
    E_STRICT => 'Runtime Notice',
  );

  // set of errors for which a var trace will be saved.
  $user_errors = array(
    E_USER_ERROR,
    E_USER_WARNING,
    E_USER_NOTICE,
  );
  if ($errno != E_STRICT) {

    // exclude Runtime Notices
    $err = $dt . "\t";
    $err .= $errno . ' ' . $errortype[$errno] . "\t";
    $err .= $errmsg . "\t";
    $err .= 'File: ' . basename($filename) . "\t";
    $err .= 'Line: ' . $linenum . "\t";
    if (in_array($errno, $user_errors)) {
      $err .= 'Trace: ' . wddx_serialize_value($vars, 'Variables') . "\t";
    }
    $err .= "\n";

    // save to the error log file, and e-mail me if there is a critical user error.
    error_log($err, 3, 'error.log');
  }
}