Creates a Result.Err containing the given error value.
Result.Err
Use this constructor when an operation fails and you want to wrap the error information in a Result type for consistent error handling.
The type of the error value.
The error value.
A Result.Err<E> containing the value.
Result.Err<E>
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.ok(Result.isErr(failure)); Copy
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.ok(Result.isErr(failure));
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.