Class Err<E>

Represents a failure result (Err<E>), encapsulating an error.

Type Parameters

  • E

    The type of the error.

Hierarchy (view full)

Constructors

Methods

  • Executes the ifErr function with the contained error.

    Type Parameters

    • U

      The return type.

    Parameters

    • ifErr: ((error: E) => U)

      Function applied to the error.

        • (error): U
        • Parameters

          • error: E

          Returns U

    • _ifOk: ((value: never) => U)

      (Unused) Function for Ok<T>.

        • (value): U
        • Parameters

          • value: never

          Returns U

    Returns U

    • The result of ifErr(error).
  • Maps the successful value, but since this is Err<E>, it remains unchanged.

    Type Parameters

    • U

      The transformed success type.

    Parameters

    • _fn: ((value: never) => U)

      Unused transformation function.

        • (value): U
        • Parameters

          • value: never

          Returns U

    Returns Result<U, E>

    • Returns itself.
  • Maps the error to another error type.

    Type Parameters

    • F

      The transformed error type.

    Parameters

    • fn: ((error: E) => F)

      The function to transform the error.

        • (error): F
        • Parameters

          • error: E

          Returns F

    Returns Result<never, F>

    • A new Err<F> with the transformed error.
  • Retrieves the provided default value since Err<E> contains nothing.

    Type Parameters

    • T

      The success type.

    Parameters

    • defaultValue: T

      The fallback value.

    Returns T

    • The provided default value.