Table of Contents

Method ValueOrThrow

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

ValueOrThrow<T>(Task<Maybe<T>>, Func<Exception>)

Returns the value the task gives if there is one, and throws the exception produced by the given function otherwise.

public static Task<T> ValueOrThrow<T>(this Task<Maybe<T>> a, Func<Exception> onNone)

Parameters

a Task<Maybe<T>>

The task giving the value to read.

onNone Func<Exception>

Run to give the exception to throw when there is no value.

Returns

Task<T>

A task giving the contained value.

Type Parameters

T

The type of the value, when there is one.

Remarks

The exception faults the task from this call, and does not come out of this call. No code knows if there is a value until the task completes.