Function errorStepWithRepeat

  • Experimental

    Executes a function and displays an interactive message bubble if an error occurs, with options to retry or close.

    Designed to enhance error handling in automated processes. If the provided function (fn) throws an error, a message bubble is displayed with options to retry or close the bubble. The process is repeated until success or the user chooses to close the bubble.

    Useful for scenarios where immediate user intervention might be required, such as continuous unexpected host changes or issues in an automation flow.

    Type Parameters

    • T

    Parameters

    • ctx: Context

      The context for automation.

    • fn: (() => Promise<T>)

      The main function to be executed. If this function throws an error, the user is presented with a retry option.

        • (): Promise<T>
        • Returns Promise<T>

    • Optional options: ErrorStepWithRepeatOptions

      Options to customize the error message, retry mechanism, and UI elements.

    Returns Promise<T | undefined>

    The return value of the function fn if successful, or undefined if the user elects to close the retry bubble.

    Example

    await errorStepWithRepeat(ctx, async () => {
    await someOperation();
    }, {
    errorMsg: "An error occurred. Please fix the issue and try again.",
    title: "Error Detected",
    description: "Ice cream machine is broken. Please fix the issue and try again.",
    loaderTitle: "Attempting to Resolve...",
    showLoader: true
    });