From 34b0aa0cb3ff2028ac789caa2082f7208bfcb851 Mon Sep 17 00:00:00 2001
From: liumiao <495261512@qq.com>
Date: 星期二, 02 二月 2021 14:00:57 +0800
Subject: [PATCH] 增加错误提示

---
 app/Exceptions/Handler.php |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 59d80e7..1474064 100644
--- a/app/Exceptions/Handler.php
+++ b/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));

--
Gitblit v1.8.0