/**
 * @param int $errno         contains the level of the error raised
 * @param string $errstr     contains the error message
 * @param string $errfile    optional: contains the filename that the error was raised in
 * @param int $errline       optional: contains the line number the error was raised at
 * @param array $errcontext  optional: an array that points to the active symbol table at the point the error occurred
 */
function v6_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
{
    $errno = $errno & error_reporting();
    if ($errno == 0) {
        return;
    }
    // in some cases, I have found these two have not been defined in some versions/builds of PHP.
    //  Oddness, so I define them if not defined already
    if (!defined('E_STRICT')) {
        define('E_STRICT', 2048);
    }
    if (!defined('E_RECOVERABLE_ERROR')) {
        define('E_RECOVERABLE_ERROR', 4096);
    }
    print "<pre>\n<b>";
    switch ($errno) {
        case E_ERROR:
            print "Error";
            break;
        case E_WARNING:
            print "Warning";
            break;
        case E_PARSE:
            print "Parse Error";
            break;
        case E_NOTICE:
            print "Notice";
            break;
        case E_CORE_ERROR:
            print "Core Error";
            break;
        case E_CORE_WARNING:
            print "Core Warning";
            break;
        case E_COMPILE_ERROR:
            print "Compile Error";
            break;
        case E_COMPILE_WARNING:
            print "Compile Warning";
            break;
        case E_USER_ERROR:
            print "User Error";
            break;
        case E_USER_WARNING:
            print "User Warning";
            break;
        case E_USER_NOTICE:
            print "User Notice";
            break;
        case E_STRICT:
            print "Strict Notice";
            break;
        case E_RECOVERABLE_ERROR:
            print "Recoverable Error";
            break;
        default:
            print "Unknown error ({$errno})";
            break;
    }
    print ":</b> <i>{$errstr}</i> in <b>{$errfile}</b> on line <b>{$errline}</b>\n";
    v6_BackTrace();
    // display all variables in scope at the time the SHTF
    if (isset($errcontext) == true) {
        print var_export($errcontext, true);
    }
    print "\r\n</pre>";
    if (isset($GLOBALS['error_fatal'])) {
        if ($GLOBALS['error_fatal'] & $errno) {
            die('fatal ' . $GLOBALS['error_fatal'] . '  ' . $errno);
        }
    }
}
Esempio n. 2
0
function handleShutdown()
{
    v6_debug::dump();
    // 12/28/2014 - set the cookie.  May not want this in production if there is an error, etc.  You may need to move
    // this into the if clause below
    v6_cookie::set();
    @ob_end_flush();
    $error = error_get_last();
    if ($error !== NULL && $error['type'] == 1) {
        //        ob_end_clean();   // silently discard the output buffer contents.
        //        appSendMsgToVern('Error has occurred',$error);
        //        header( 'location:/fatal_error' );
        @ob_end_flush();
        // output what is stored in the internal buffer  (may not want this here in production)
        echo '<pre>' . var_export($error, true);
        v6_BackTrace();
        die('handleShutdown(): Cannot continue!');
    } else {
        @ob_end_flush();
        // output what is stored in the internal buffer
    }
}