Browse Source

fix: loop elements throw error

Ahmad Kholid 3 years ago
parent
commit
a5b59b0c1c

+ 4 - 0
src/background/workflowEngine/blocksHandler/handlerLoopData.js

@@ -93,6 +93,10 @@ async function loopData({ data, id, outputs }, { refData }) {
   } catch (error) {
   } catch (error) {
     error.nextBlockId = nextBlockId;
     error.nextBlockId = nextBlockId;
 
 
+    if (data.loopThrough === 'elements') {
+      error.data = { selector: data.elementSelector };
+    }
+
     throw error;
     throw error;
   }
   }
 }
 }

+ 6 - 0
src/content/index.js

@@ -60,6 +60,12 @@ import handleTestCondition from './handleTestCondition';
             documentCtx
             documentCtx
           );
           );
 
 
+          if (!elements || elements?.length === 0) {
+            reject(new Error('element-not-found'));
+
+            return;
+          }
+
           elements.forEach((el, index) => {
           elements.forEach((el, index) => {
             if (data.max > 0 && selectors.length - 1 > data.max) return;
             if (data.max > 0 && selectors.length - 1 > data.max) return;