Class FailureOr<TValue>

A discriminated union of either a value or a list of failures

Export

FailureOr

Implements

Type Parameters

  • TValue

Implements

Constructors

Properties

_failures?: Failure[]
_value?: TValue
isFailure: boolean

Gets a value indicating whether the result is a failure

Memberof

FailureOr

isSuccess: boolean

Gets a value indicating whether the result is a success

Memberof

FailureOr

Accessors

  • get failuresOrEmptyList(): Failure[]
  • Gets the list of failures. If the state is a success, this will return an empty list.

    Returns Failure[]

    Memberof

    FailureOr

  • get firstFailure(): Failure
  • Gets the first error. If the state is a success, this will return a failure indicating that no first failure exists.

    Returns Failure

    Memberof

    FailureOr

  • get value(): TValue
  • Gets the value. If the state is a failure, this will throw an error.

    Returns TValue

    Throws

    If the state is a failure

    Memberof

    FailureOr

Methods

  • Executes the appropriate callback based on the state of the . If the state is a success, the onValue callback will be executed and its result is returned. If the state is a failure, the onFailure callback will be executed and its result is returned.

    Type Parameters

    • TResult

    Parameters

    Returns TResult

    {TResult}

    Memberof

    FailureOr

  • Executes the appropriate callback based on the state of the . If the state is a success, the onValue callback will be executed and its result is returned. If the state is a failure, the onFailure callback will be executed and its result is returned.

    Type Parameters

    • TResult

    Parameters

    Returns Promise<TResult>

    {Promise}

    Memberof

    FailureOr

  • Executes the appropriate callback based on the state of the . If the state is a success, the onValue callback will be executed and its result is returned. If the state is a failure, the onFailure callback will be executed using the first failure as input and its result is returned.

    Type Parameters

    • TResult

    Parameters

    Returns TResult

    {TResult}

    Memberof

    FailureOr

  • Executes the appropriate callback based on the state of the . If the state is a success, the onValue callback will be executed and its result is returned. If the state is a failure, the onFailure callback will be executed using the first failure as input and its result is returned.

    Type Parameters

    • TResult

    Parameters

    Returns Promise<TResult>

    {Promise}

    Memberof

    FailureOr

  • Executes the appropriate callback based on the state of the . If the state is a success, the onValue callback will be executed. If the state is a failure, the onFailure callback will be executed.

    Parameters

    • onValue: ((value) => void)
        • (value): void
        • Parameters

          Returns void

    • onFailure: ((failures) => void)
        • (failures): void
        • Parameters

          Returns void

    Returns void

    Memberof

    FailureOr

  • Executes the appropriate callback based on the state of the . If the state is a success, the onValue callback will be executed. If the state is a failure, the onFailure callback will be executed.

    Parameters

    • onValue: ((value) => Promise<void>)
        • (value): Promise<void>
        • Parameters

          Returns Promise<void>

    • onFailure: ((failures) => Promise<void>)
        • (failures): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns Promise<void>

    {Promise}

    Memberof

    FailureOr

  • Executes the appropriate callback based on the state of the . If the state is a success, the onValue callback will be executed. If the state is a failure, the onFailure callback will be executed using the first failure as input.

    Parameters

    • onValue: ((value) => void)
        • (value): void
        • Parameters

          Returns void

    • onFailure: ((failure) => void)
        • (failure): void
        • Parameters

          Returns void

    Returns void

    Memberof

    FailureOr

  • Executes the appropriate callback based on the state of the . If the state is a success, the onValue callback will be executed. If the state is a failure, the onFailure callback will be executed using the first failure as input.

    Parameters

    • onValue: ((value) => Promise<void>)
        • (value): Promise<void>
        • Parameters

          Returns Promise<void>

    • onFailure: ((failure) => Promise<void>)
        • (failure): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns Promise<void>

    {Promise}

    Memberof

    FailureOr

Generated using TypeDoc