Represents a structured error with a label for identification and a source error.
A string literal type for the error label.
The type of the source error.
Returns a ResultErr containing this error and null.
null
A ResultErr.
const [error, value] = new Err("my_error").result();// error is { label: "my_error", source: Error("my_error") }// value is null Copy
const [error, value] = new Err("my_error").result();// error is { label: "my_error", source: Error("my_error") }// value is null
Performs a side effect with the error, then returns the error instance for chaining.
The function to execute for the side effect.
The Err instance.
Err
const [error, value] = new Err("my_error").tap(e => console.error(e.source)).result(); Copy
const [error, value] = new Err("my_error").tap(e => console.error(e.source)).result();
Optional
Readonly
The label identifying the type of error.
The source of the error. Can be any value, but typically an Error object.
Error
Represents a structured error with a label for identification and a source error.