改变严重错误的行为

来源:互联网 发布:手机色彩搭配软件 编辑:程序博客网 时间:2024/04/30 04:02
自CakePHP 2.2错误。处理程序将收到致命的错误代码。如果你不想显示蛋糕错误页面,你可以覆盖它:
//in app/Config/core.phpConfigure::write('Error.handler', 'AppError::handleError');//in app/Config/bootstrap.phpApp::uses('AppError', 'Lib');//in app/Lib/AppError.phpclass AppError {    public static function handleError($code, $description, $file = null,        $line = null, $context = null) {        list(, $level) = ErrorHandler::mapErrorCode($code);        if ($level === LOG_ERROR) {            // Ignore fatal error. It will keep the PHP error message only            return false;        }        return ErrorHandler::handleError(            $code,            $description,            $file,            $line,            $context        );    }}

如果你想保持默认的致命错误的行为,你可以叫ErrorHandler:handleFatalError()从您的自定义处理程序。
0 0
原创粉丝点击