Explorar o código

修改bug提醒发送限制

kevin_zhangl %!s(int64=3) %!d(string=hai) anos
pai
achega
8d2174c693
Modificáronse 1 ficheiros con 17 adicións e 45 borrados
  1. 17 45
      vendor/yiisoft/yii2/web/ErrorHandler.php

+ 17 - 45
vendor/yiisoft/yii2/web/ErrorHandler.php

@@ -150,56 +150,28 @@ class ErrorHandler extends \yii\base\ErrorHandler
             $exception = new HttpException(500, Yii::t('yii', 'An internal server error occurred.'));
         }
 
-        $errorOutline = ['AR_', 'PHP', 'Undefined', 'Undefined index', 'SQLSTATE'];
-        foreach ($errorOutline as $item) {
-            if (false !== strpos($exception->getMessage(), $item)) {
-                $it = [
-                    'name' => ($exception instanceof Exception || $exception instanceof ErrorException) ? $exception->getName() : 'Exception',
-                    'message' => '(NC)提醒:' . $exception->getMessage(),
-                    'code' => $exception->getCode(),
-                ];
-                if ($exception instanceof HttpException) {
-                    $it['status'] = $exception->statusCode;
-                }
-                if (YII_DEBUG) {
-                    $it['type'] = get_class($exception);
-                    if (!$exception instanceof UserException) {
-                        $it['file'] = $exception->getFile();
-                        $it['line'] = $exception->getLine();
-                        $it['stack-trace'] = explode("\n", $exception->getTraceAsString());
-                        if ($exception instanceof \yii\db\Exception) {
-                            $it['error-info'] = $exception->errorInfo;
-                        }
-                    }
-                }
-                if (($prev = $exception->getPrevious()) !== null) {
-                    $it['previous'] = $this->convertExceptionToArray($prev);
-                }
-
-                // 错误日志写入
-                $it['trace-id'] = Tool::generateId();
-                LoggerTool::error($it);
-
-                // 提醒只报出基本错误
-                unset($it['stack-trace']);
-                // 发送钉钉提醒
-                DingTalk::sendNotice($it);
-
-                $array = [
-                    'name' => ($exception instanceof Exception || $exception instanceof ErrorException) ? $exception->getName() : 'Exception',
-                    'message' => '请求错误.请联系客服人员',
-                    'code' => $exception->getCode(),
-                ];
-
-                return $array;
-            }
-        }
-
         $array = [
             'name' => ($exception instanceof Exception || $exception instanceof ErrorException) ? $exception->getName() : 'Exception',
             'message' => $exception->getMessage(),
             'code' => $exception->getCode(),
         ];
+        if ($exception instanceof HttpException) {
+            $array['status'] = $exception->statusCode;
+        }
+        if (YII_DEBUG) {
+            $array['type'] = get_class($exception);
+            if (!$exception instanceof UserException) {
+                $array['file'] = $exception->getFile();
+                $array['line'] = $exception->getLine();
+                $array['stack-trace'] = explode("\n", $exception->getTraceAsString());
+                if ($exception instanceof \yii\db\Exception) {
+                    $array['error-info'] = $exception->errorInfo;
+                }
+            }
+        }
+        if (($prev = $exception->getPrevious()) !== null) {
+            $array['previous'] = $this->convertExceptionToArray($prev);
+        }
 
         return $array;
     }