Aller au contenu principal

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