Function isErr

  • Type guard to check if a Result is an Err value. This function is used to narrow down the type of a Result to ErrResult in TypeScript type system.

    Type Parameters

    • T extends NonUndefined
    • E extends NonUndefined

    Parameters

    • val: Result<T, E>

      The Result to be checked.

    Returns val is ErrResult<never, E>

    true if the provided Result is an ErrResult, false otherwise.

    const result = Err('Failure');
    if (isErr(result)) {
    console.log('Operation failed with error:', result.unwrapErr());
    }

    Use Result.isErr instead.