Example #1
0
/**
 * Global exception handler
 */
function exception_handler($exception)
{
    // TODO: Error logging via email, page redirect on error
    try {
        uses_system('mail/mail');
        $session = Session::Get();
        email('error/exception', '*****@*****.**', '*****@*****.**', '[EXCEPTION] ' . $exception->getMessage(), array('session' => $session, 'exception' => $exception));
    } catch (Exception $ex) {
    }
    include PATH_PUB . 'ohnoes.html';
}
Example #2
0
/**
 * Debug error handler
 */
function error_handler($errno, $errstr, $errfile, $errline)
{
    if ($errno == E_USER_ERROR) {
        echo "<b>ERROR</b> [{$errno}] {$errstr}<br />\n";
        echo "  Fatal error on line {$errline} in file {$errfile}";
        echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
        echo "Aborting...<br />\n";
        exit(1);
        return;
    }
    // ignore adodb warnings
    if (strpos($errfile, "adodb") === false && strpos($errstr, "Deprecated") === false) {
        // create a hash of the error
        $error = md5($errfile . $errline . $errstr);
        global $error_cache;
        // if error isn't in cache ...
        if (!isset($error_cache[$error])) {
            global $page_errors;
            $page_errors[] = array("errno" => $errno, "errstr" => $errstr, "errfile" => $errfile, "errline" => $errline);
            // add to cache so that we won't log the bug again
            $error_cache[$error] = 1;
        }
        if (strpos($errstr, 'require_once') === 0) {
            uses_system('debug/trace');
            return;
        }
    }
    return true;
}