Skip to main content

Err<T, E>

Represents an error result containing an error value.

Since​

2.0.0


Type Parameters​

T: T​

The type of the success value (unused in Err)

E: E​

The type of the error value


Implements​

  • IResult<T, E>

Constructors​

Constructor​

Creates a new Err result.

error: E β€” The error value to wrap
Returns: Err<T, E>


Properties​

error: E​

The error value to wrap


Methods​

isOk()​

Always returns false for Err instances.

Returns: this is Ok<T, E>​

false

Implementation of: IResult.isOk​

isErr()​

Always returns true for Err instances. Optimized to return the constant value directly.

Returns: this is Err<T, E>​

true

Implementation of: IResult.isErr​

map()​

No-op for Err instances - the value transformation function is ignored.

Type Parameters​

A: A​

The type of the transformed value (unused)

_f: (t) => A β€” Transformation function (ignored)
Returns: Result<A, E> β€” A new Err result with the original error

Implementation of: IResult.map​

mapErr()​

Transforms the error value using the provided function.

Type Parameters​

U: U​

The type of the transformed error

f: (e) => U β€” Function to transform the error value
Returns: Result<T, U> β€” A new Err result with the transformed error

Implementation of: IResult.mapErr​

andThen()​

Call Signature​

No-op for Err instances - the chaining function is ignored.

Type Parameters​
R: R extends Result<unknown, unknown>​

The type of the Result returned by the function (unused)

_f: (t) => R β€” Chaining function (ignored)
Returns: Result<InferOkTypes<R>, E | InferErrTypes<R>> β€” A new Err result with the original error

Implementation of: IResult.andThen​

Call Signature​

No-op for Err instances with explicit type parameters.

Type Parameters​
U: U​

The type of the success value in the returned Result (unused)

F: F​

The type of the error value in the returned Result (unused)

_f: (t) => Result<U, F> β€” Chaining function (ignored)
Returns: Result<U, E | F> β€” A new Err result with the original error

Implementation of: IResult.andThen​

unwrapOr()​

Always returns the default value for Err instances.

Type Parameters​

A: A​

The type of the default value

v: A β€” Default value to return
Returns: T | A β€” The default value

Implementation of: IResult.unwrapOr​

match()​

Executes the error function with the error value.

Type Parameters​

A: A​

The return type for the success case (unused)

B: B = A​

The return type for the error case

_ok: (t) => A β€” Success function (ignored)
err: (e) => B β€” Function to execute with the error value
Returns: A | B β€” The result of executing the error function

Implementation of​

IResult.match