Exemplo n.º 1
0
function error_user_handler($errno, $errstr, $errfile, $errline)
{
    # check if errors were disabled with @ somewhere in this call chain
    if (0 == error_reporting()) {
        return;
    }
    # format error message for writing to mail and logs
    $err_msg = error_format($errno, $errstr, $errfile, $errline);
    switch ($errno) {
        // system warning
        case E_WARNING:
            error_admin_alert($err_msg);
            if (ON == SHOW_WARNINGS) {
                error_user_message('System Warning', $errstr, $errfile, $errline);
                die;
            }
            break;
            // system notice
        // system notice
        case E_NOTICE:
            error_admin_alert($err_msg);
            if (ON == SHOW_NOTICES) {
                error_user_message('System Notice', $errstr, $errfile, $errline);
                die;
            }
            break;
            // user-triggered fatal error
        // user-triggered fatal error
        case E_USER_ERROR:
            error_admin_alert($err_msg);
            error_user_message('User Defined Error', error_get_user_message($errstr), $errfile, $errline);
            die;
            break;
            // user-triggered warning
        // user-triggered warning
        case E_USER_WARNING:
            // not currently used
            error_user_message('User Defined Warning', error_get_user_message($errstr), $errfile, $errline);
            error_admin_alert($err_msg);
            break;
            // user-triggered notice
        // user-triggered notice
        case E_USER_NOTICE:
            // not currently used
            error_user_message('User Defined Notice', error_get_user_message($errstr), $errfile, $errline);
            error_admin_alert($err_msg);
            break;
    }
}
Exemplo n.º 2
0
/**
 * Formats error strings into an error group container as deteremined by mode
 * @param array/string error The error strings to format
 * @param string mode Either 'text' or 'html'; defaults to 'html'
 * @return string Returns formatted errors in an error group container
 */
function error_compile($errors, $mode = "html")
{
    // Default to html mode for output
    if ($mode != "html" || $mode != "text") {
        $mode = "html";
    }
    // Always handle as an array
    if (!is_array($errors)) {
        $errors = array($errors);
    }
    // Get necessary templates
    $forms = multiform(PATH_TEMPLATES_STUBS . "errors.gform.html");
    $error_str = "";
    // Make all of the errors into one string
    foreach ($errors as $err) {
        $error_str .= error_format($err, $mode, $forms);
    }
    // Format the error items into the error item group
    return sprintf($forms['error-group-' . $mode], $error_str);
}