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