Function tryCatch

  • Wraps and invokes a function and catches any errors that are thrown. Promises are also handled.

    Type Parameters

    • R

      The type of the return value of the function or promise.

    Parameters

    • fn: (() => R | Promise<R>)

      The function or promise to wrap.

        • (): R | Promise<R>
        • Returns R | Promise<R>

    Returns Promise<[Error | undefined, R | undefined]>

    a tuple with the error and the result.

Generated using TypeDoc