Function Err

  • Creates an Err instance of Result containing the error value. This function is used to represent a failure in operations that could potentially fail.

    Type Parameters

    • T extends NonUndefined
    • E extends NonUndefined

    Parameters

    • val: E

      The error value to be contained within the Err Result.

    Returns ErrResult<T, E>

    A Result instance representing an error and containing the provided error value.

    const errorResult = Err('Something went wrong');
    console.log(errorResult.unwrapErr()); // Outputs: Something went wrong