ts-fortress
    Preparing search index...

    Variable errConst

    err: <const E>(value: E) => Err<E>

    Creates a Result.Err containing the given error value.

    Use this constructor when an operation fails and you want to wrap the error information in a Result type for consistent error handling.

    Type Declaration

      • <const E>(value: E): Err<E>
      • Type Parameters

        • const E

          The type of the error value.

        Parameters

        • value: E

          The error value.

        Returns Err<E>

        A Result.Err<E> containing the value.

    const success = Result.ok({ id: 1 });

    const failure = Result.err(new Error('missing data'));

    assert.deepStrictEqual(success, {
    $$tag: 'ts-data-forge::Result.ok',
    value: { id: 1 },
    });

    assert.isTrue(Result.isErr(failure));