|
|
@@ -150,6 +150,51 @@ 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', 'Trying to access array offset on value of type null'];
|
|
|
+ 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(),
|