فهرست منبع

添加错误处理

visuddhinanda 4 روز پیش
والد
کامیت
9d1275d414
1فایلهای تغییر یافته به همراه24 افزوده شده و 19 حذف شده
  1. 24 19
      api-v13/app/Console/Commands/UpgradeAITranslation.php

+ 24 - 19
api-v13/app/Console/Commands/UpgradeAITranslation.php

@@ -348,25 +348,30 @@ class UpgradeAITranslation extends Command
     private function save(array $data)
     private function save(array $data)
     {
     {
         // 写入句子库
         // 写入句子库
-        $sentData = [];
-        $sentData = array_map(function ($n) {
-            $sId = explode('-', $n['id']);
-
-            return [
-                'book_id' => $sId[0],
-                'paragraph' => $sId[1],
-                'word_start' => $sId[2],
-                'word_end' => $sId[3],
-                'channel_uid' => $this->workChannel['id'],
-                'content' => $n['content'],
-                'content_type' => $n['content_type'] ?? 'markdown',
-                'lang' => $this->workChannel['lang'],
-                'status' => $this->workChannel['status'],
-                'editor_uid' => $this->model['uid'],
-            ];
-        }, $data);
-        foreach ($sentData as $key => $value) {
-            $this->sentenceService->saveWithHistory($value);
+        try {
+            $sentData = [];
+            $sentData = array_map(function ($n) {
+                $sId = explode('-', $n['id']);
+
+                return [
+                    'book_id' => $sId[0],
+                    'paragraph' => $sId[1],
+                    'word_start' => $sId[2],
+                    'word_end' => $sId[3],
+                    'channel_uid' => $this->workChannel['id'],
+                    'content' => $n['content'],
+                    'content_type' => $n['content_type'] ?? 'markdown',
+                    'lang' => $this->workChannel['lang'],
+                    'status' => $this->workChannel['status'],
+                    'editor_uid' => $this->model['uid'],
+                ];
+            }, $data);
+            foreach ($sentData as $key => $value) {
+                $this->sentenceService->saveWithHistory($value);
+            }
+        } catch (\Exception $e) {
+            $this->error($e->getMessage());
+            throw $e;
         }
         }
     }
     }
 }
 }