ctx.exit()
Terminates the execution of the current event flow; subsequent steps will not run. It is commonly used when business conditions are not met, the user cancels, or an irrecoverable error occurs.
Use Cases
ctx.exit() is generally used in the following contexts where JS can be executed:
Difference from
ctx.exitAll():ctx.exit()only terminates the current event flow; other event flows under the same event are not affected.ctx.exitAll()terminates the current event flow as well as any subsequent event flows under the same event that have not yet been executed.
Type Definition
Calling ctx.exit() throws an internal FlowExitException, which is caught by the FlowEngine to stop the current event flow execution. Once called, the remaining statements in the current JS code will not execute.
Comparison with ctx.exitAll()
Examples
Exit on User Cancellation
Exit on Parameter Validation Failure
Exit When Business Conditions Are Not Met
Choosing Between ctx.exit() and ctx.exitAll()
Exit Based on User Choice After Modal Confirmation
Notes
- After calling
ctx.exit(), subsequent code in the current JS will not execute; it is recommended to explain the reason to the user viactx.message,ctx.notification, or a modal before calling it. - There is usually no need to catch
FlowExitExceptionin business code; let the FlowEngine handle it. - If you need to terminate all subsequent event flows under the current event, use
ctx.exitAll().
Related
- ctx.exitAll(): Terminates the current event flow and subsequent event flows under the same event.
- ctx.message: Message prompts.
- ctx.modal: Confirmation modals.

