Codeigniter:显示多次相同的全局异常

时间:2014-08-07 09:15:25

标签: php codeigniter

我正在使用codeigniter&通过扩展Exception类

在php的帮助下显示全局异常

现在问题是:在同一页面上异常消息(见屏幕截图)显示多次,具体取决于生成的异常数量...我想在浏览器中只向用户显示消息...

如何在浏览器中只显示一条消息?

生成异常消息的代码     

    function __construct() {
        parent::__construct();
    } 

    function log_exception($severity, $message, $filepath, $line) {

        if (ENVIRONMENT === 'production') {
            $to = "developer@example.com";
            $subject = "Fitness Trainer -Production Exception";
            $message = 'Severity: ' . $severity . '  --> ' . $message . ' ' . $filepath . '<br/> ' . $line;
            $from = "robot@gmail.com";
            $headers = "From:" . $from;
            mail($to, $subject, $message, $headers);
            echo '<div  style="width: 70%;text-align: left;margin-left: 15%;" class="alert alert-warning text-center alert-dismissible server-side-msg text-capitalize"   role="alert">
                <span class="glyphicon glyphicon-warning-sign"></span>
                <strong>We apologize for the inconvenience,An exception occurred from our side and will work to resolve it....
                </strong>
                <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            </div>';
        }  
        parent::log_exception($severity, $message, $filepath, $line);
    } 
}?>

重复消息的屏幕截图 enter image description here

0 个答案:

没有答案