Skip to content

Commit ad2b575

Browse files
committed
feat: update error handling in flows to return errors instead of throwing
1 parent 6437691 commit ad2b575

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/execution-flow/flows/clickon-flow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const clickOnFlow = createFlow<ClickAction>({
5252

5353
onError: (_, step) => {
5454
const targetDescription = clickOnDescription(step);
55-
throw new ElementNotFoundError(`Element missing: ${targetDescription}`);
55+
return new ElementNotFoundError(`Element missing: ${targetDescription}`);
5656
},
5757
});
5858

src/execution-flow/flows/is-disabled-flow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const isDisabledFlow = createFlow<IsDisabledAction>({
5151
},
5252
onError(_, step) {
5353
const targetDescription = isDisableDescription(step);
54-
throw new FailedAssertionError(`Assertion failed: ${targetDescription}`);
54+
return new FailedAssertionError(`Assertion failed: ${targetDescription}`);
5555
},
5656
});
5757

src/execution-flow/flows/is-not-visible-flow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ export default async function isNotVisibleFlow({
3636
isNotVisibleSpiner.stop(
3737
`${chalk.red("✖")} isNotVisible: Element is visible with ${targetDescription}`,
3838
);
39-
throw new FailedAssertionError(`Assertion failed: ${targetDescription}`);
39+
return new FailedAssertionError(`Assertion failed: ${targetDescription}`);
4040
}
4141
}

src/execution-flow/flows/istitle-flow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const isTitleFlow = createFlow<IsTitleAction>({
2626
},
2727
onError(_, step) {
2828
const { value: titleOrRegex } = regexOrStringMaker(step.isTitle);
29-
throw new FailedAssertionError(`Assertion failed: ${titleOrRegex}`);
29+
return new FailedAssertionError(`Assertion failed: ${titleOrRegex}`);
3030
},
3131
});
3232
export default isTitleFlow;

src/execution-flow/flows/isurl-flow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const isURLFlow = createFlow<IsURLAction>({
3232

3333
onError(_, step) {
3434
const { value: titleOrRegex } = regexOrStringMaker(step.isURL);
35-
throw new FailedAssertionError(`Assertion failed: ${titleOrRegex}`);
35+
return new FailedAssertionError(`Assertion failed: ${titleOrRegex}`);
3636
},
3737
});
3838

src/execution-flow/flows/isvisible-flow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const isVisibleFlow = createFlow<IsVisibleAction>({
5050
},
5151
onError(_, step) {
5252
const targetDescription = isVisisbleDescription(step);
53-
throw new FailedAssertionError(`Assertion failed: ${targetDescription}`);
53+
return new FailedAssertionError(`Assertion failed: ${targetDescription}`);
5454
},
5555
});
5656

0 commit comments

Comments
 (0)