liumiao
2021-02-02 34b0aa0cb3ff2028ac789caa2082f7208bfcb851
增加错误提示
1 files modified
29 ■■■■ changed files
app/Exceptions/Handler.php 29 ●●●● patch | view | raw | blame | history
app/Exceptions/Handler.php
@@ -108,7 +108,7 @@
//        }
        elseif($routeSystem == 'api')
        {
            return apiResponse('', ResponseCode::SERVER_ERROR, $e->getMessage(). ' file :' . $e->getFile(). ' line :' .  $e->getLine());
            return apiResponse('', ResponseCode::SERVER_ERROR, $e->getMessage() . ' file :' . $e->getFile() . ' line :' . $e->getLine());
        }
        elseif($e instanceof ResponseException)
        {
@@ -198,7 +198,6 @@
        $errInfo['file'] = $e->getFile();           //错误文件
        $errInfo['line'] = $e->getLine();           //错误行数
        $errInfo['params'] = $request->all();       //所有参数
        if($routeSystem == 'api')
        {
            if($e instanceof MethodNotAllowedHttpException)
@@ -211,11 +210,28 @@
            }
            elseif($e instanceof QueryException)
            {
//                return $this->responseAndLogV2(ResponseCode::SERVER_ERROR, '数据库错误', $errInfo, 'error');
                $message = '';
                if(strpos($e, 'insert'))
                {
                    $message = '数据插入错误';
                }
                if(strpos($e, 'update'))
                {
                    $message = '数据更新错误';
                }
                if(strpos($e, 'delete'))
                {
                    $message = '数据删除错误';
                }
                if(strpos($e, 'select'))
                {
                    $message = '数据查询错误';
                }
                return $this->responseAndLogV2(ResponseCode::SERVER_ERROR, $message, $errInfo, 'error');
            }
            elseif($e instanceof ApiException)
            {
                return $this->responseAndLogV2($errInfo['code'],$errInfo['message'], $errInfo, 'error');
                return $this->responseAndLogV2($errInfo['code'], $errInfo['message'], $errInfo, 'error');
            }
            else
            {
@@ -251,7 +267,7 @@
         * debug        调试
         */
        //文件记录
        $this->recordLogByFile($logLevel,$errInfo);
        $this->recordLogByFile($logLevel, $errInfo);
//        //ES记录
//        $this->recordLogByES($errInfo);
@@ -268,7 +284,8 @@
     */
    private function recordLogByFile($logLevel, $errInfo)
    {
        if(is_array($errInfo)) {
        if(is_array($errInfo))
        {
            $errInfo['request'] = \Request::url();
        }
        Log::$logLevel(json_encode($errInfo));