⚠️ Internal: This API is not publically exported by the package.
  • Run a function without the risk that the function will throw an error. Errors will be returned as part of the return object instead of throwing.

    Type Parameters

    • T extends ((...args) => Promise<unknown>)

    Parameters

    • functionToRun: T
    • Rest ...functionParams: Parameters<T>

    Returns Promise<{
        error?: never;
        hasError: false;
        value: Awaited<ReturnType<T>>;
    } | {
        error: unknown;
        hasError: true;
        value: undefined;
    }>