示例#1
0
function regError($msg)
{
    // Development
    echo '<pre>' . $msg . '</pre><hr>';
    /*
    // Production
    $logger = null;
    $mailer = new Mailer;
    
    // Initialize logger
    try{
        $logger = new FileLogger(LOG_FILE);
    }catch(Exception $e){
        try{
            $mailer->compose('*****@*****.**', ADMIN_EMAIL, PROJECT_NAME . ' - Logger error', $e->__toString());
            $mailer->sendMail();
        }catch(phpmailerException $pme){
            $mailer = null;
    
            // Write errors to default PHP log
            error_log($e->__toString());
            error_log($pme->__toString());
        }
    }
    
    // Log error
    if($logger !== null) $logger->error($msg);
    
    if($mailer !== null){
        try{
            // Alert admin by mail        
            $mailer->compose('*****@*****.**', ADMIN_EMAIL, PROJECT_NAME . ' - Unexpected error', $msg);
            $mailer->sendMail();
        }catch(phpmailerException $pme){
            ($logger !== null) ? $logger->error($pme->__toString()) : error_log($pme->__toString());
        }          
    }
    */
    // Display error page to user
    $error = new ErrorController();
    $error->show();
    redirect(404);
}