Browse Source

feat: When a task block throws an error, users can customize the error message.

zhaosi 1 year ago
parent
commit
630d06fed7

+ 7 - 0
src/components/newtab/workflow/edit/BlockSetting/BlockSettingOnError.vue

@@ -79,6 +79,13 @@
             {{ t(`workflow.blocks.base.onError.toDo.${type}`) }}
             {{ t(`workflow.blocks.base.onError.toDo.${type}`) }}
           </option>
           </option>
         </ui-select>
         </ui-select>
+        <ui-input
+          v-if="state.toDo === 'error'"
+          v-model="state.errorMessage"
+          :placeholder="t(`workflow.blocks.workflow-state.error.message`)"
+          :title="t(`workflow.blocks.workflow-state.error.message`)"
+          class="mt-1 ml-2 w-56"
+        />
         <div class="mt-4 flex items-center justify-between">
         <div class="mt-4 flex items-center justify-between">
           <label class="inline-flex">
           <label class="inline-flex">
             <ui-switch v-model="state.insertData" />
             <ui-switch v-model="state.insertData" />

+ 1 - 0
src/components/newtab/workflow/edit/EditBlockSettings.vue

@@ -75,6 +75,7 @@ const defaultSettings = {
     retryTimes: 1,
     retryTimes: 1,
     retryInterval: 2,
     retryInterval: 2,
     toDo: 'error',
     toDo: 'error',
+    errorMessage: '',
     insertData: false,
     insertData: false,
     dataToInsert: [],
     dataToInsert: [],
   },
   },

+ 5 - 1
src/locales/en/blocks.json

@@ -133,6 +133,10 @@
         "description": "Manage workflows states",
         "description": "Manage workflows states",
         "actions": {
         "actions": {
           "stop": "Stop workflows"
           "stop": "Stop workflows"
+        },
+        "error": {
+          "throwError": "Throw error",
+          "message": "Error message"
         }
         }
       },
       },
       "regex-variable": {
       "regex-variable": {
@@ -803,4 +807,4 @@
       }
       }
     }
     }
   }
   }
-}
+}

+ 5 - 1
src/locales/zh/blocks.json

@@ -133,6 +133,10 @@
         "description": "管理工作流状态",
         "description": "管理工作流状态",
         "actions": {
         "actions": {
           "stop": "停止工作流"
           "stop": "停止工作流"
+        },
+        "error": {
+          "throwError": "抛出错误",
+          "message": "错误消息"
         }
         }
       },
       },
       "regex-variable": {
       "regex-variable": {
@@ -796,4 +800,4 @@
       }
       }
     }
     }
   }
   }
-}
+}

+ 6 - 0
src/workflowEngine/WorkflowWorker.js

@@ -415,6 +415,12 @@ class WorkflowWorker {
 
 
           return;
           return;
         }
         }
+
+        // 抛出错误并且存在自定义的错误信息
+        if (blockOnError.toDo === 'error' && blockOnError.errorMessage.trim()) {
+          errorLogData.message = blockOnError.errorMessage;
+          error.message = blockOnError.errorMessage;
+        }
       }
       }
 
 
       const errorLogItem = errorLogData;
       const errorLogItem = errorLogData;