⚠️ 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. For async functions, use runSafeAsync

    Type Parameters

    • T extends ((...args) => void)

    Parameters

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

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