Method ValueOrThrow
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
ValueOrThrow<T>(Maybe<T>, Func<Exception>)
Returns the contained value if there is one, and throws the exception produced by the given function otherwise.
public static T ValueOrThrow<T>(this Maybe<T> a, Func<Exception> onNone)
Parameters
aMaybe<T>The value to read.
onNoneFunc<Exception>Run to give the exception to throw when there is no value.
Returns
- T
The contained value.
Type Parameters
TThe type of the value.
Remarks
The deliberate exit, for the boundary where the absence of a value really is a failure - a necessary configuration value, for example. It makes the caller answer for the empty condition, by making them say what the failure is.
Exceptions
- Exception
Whatever
onNoneproduced, when there is no contained value.