Helpful
    Preparing search index...

    Function tryFallback

    Invokes the candidate function and returns fallback if an error is thrown from it.

    The candidate function to run.

    The fallback value to return if candidate throws an error.

    The result from candidate. Returns fallback if candidate throws an Error. If no fallback value is provided, then undefined is returned.

    • Invokes the candidate function and returns undefined if an error is thrown from it.

      Type Parameters

      • T

      Parameters

      • candidate: () => T

        The candidate function to run.

      Returns T | undefined

      The result from candidate. Returns undefined if candidate throws an Error.

    • Invokes the candidate function and returns fallback if an error is thrown from it.

      Type Parameters

      • T

      Parameters

      • candidate: () => T

        The candidate function to run.

      • fallback: T

        The fallback value to return if candidate throws an error.

      Returns T

      The result from candidate. Returns fallback if candidate throws an Error.