The type of the potential value.
The void
error (typically omitted or undefined
).
A Result containing undefined
as Err.
const x = err<number>();
expect(x.isErr()).toBe(true);
expect(x.unwrapErr().expected).toBeUndefined();
expect(x.unwrapErr().unexpected).toBeUndefined();
Creates an Err variant of a Result containing the given error.
Wraps the provided error in a CheckedError within an Err, indicating a failed outcome for a checked Result. This function accepts raw errors, ResultError, or CheckedError.
E
, it creates an ExpectedError variant.The type of the potential value.
The type of the expected error.
The error to wrap in Err, as a raw E
, ResultError, or CheckedError.
A Result containing the error as Err.
const oops = new ResultError("err", ResultErrorKind.Unexpected);
const x = err<number, string>("failure");
const y = err<number, string>(oops);
expect(x.isErr()).toBe(true);
expect(x.unwrapErr().expected).toBe("failure");
expect(y.unwrapErr().unexpected).toBe(oops);
Creates an Err variant of a Result with a
void
error.Wraps
undefined
in a CheckedError within an Err, indicating a failed outcome with no error value for a checked Result.