Browse Source

人才申报中未捕获到的其它非验证类错误记录日志

sugangqiang 2 years ago
parent
commit
cf794386f1
1 changed files with 32 additions and 0 deletions
  1. 32 0
      app/enterprise/controller/Talent.php

+ 32 - 0
app/enterprise/controller/Talent.php

@@ -6,6 +6,7 @@ use app\enterprise\common\EnterpriseController;
 use app\enterprise\api\TalentApi;
 use app\enterprise\model\Talent as TalentModel;
 use think\facade\Db;
+use think\facade\Log;
 use app\common\api\EnterpriseApi;
 use app\common\api\DictApi;
 use app\common\api\TalentLogApi;
@@ -846,6 +847,20 @@ class Talent extends EnterpriseController {
             $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
             echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
             exit();
+        } catch (\think\Exception $e) {
+            $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
+            $logInfo = [
+                "enterprise_id" => $this->user["uid"],
+                "data" => $data,
+                "controller" => $this->request->controller(),
+                "action" => $this->request->action(),
+                "errCode" => $e->getCode(),
+                "errMsg" => $e->getMessage()
+            ];
+            Log::write($logInfo, "error");
+            $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
+            echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
+            exit();
         }
     }
 
@@ -955,6 +970,23 @@ class Talent extends EnterpriseController {
             } else {
                 return json(["msg" => $e->getMessage()]);
             }
+        } catch (\think\Exception $e) {
+            $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
+            $logInfo = [
+                "enterprise_id" => $this->user["uid"],
+                "data" => $data,
+                "controller" => $this->request->controller(),
+                "action" => $this->request->action(),
+                "errCode" => $e->getCode(),
+                "errMsg" => $e->getMessage()
+            ];
+            Log::write($logInfo, "error");
+            if ($checkState == TalentState::SCND_SAVE) {
+                echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
+                exit();
+            } else {
+                return json($res);
+            }
         }
     }