OptTThrowIfNoneE(FuncE) Method

Returns the option back when IsSome; throws a custom exception when IsNone. Exception thrown when IsNone is created by the provided method getException. Can be called without breaking the flow of chained operations.
C#
var interestRate = GetOptionalUser(input)
    .ThrowIfNone(() => new ArithmeticException("sth went wrong"))
    .Map(user => ComputeInterestRate(user))
    .Unwrap();

Definition

Namespace: Orx.Fun.Option
Assembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
C#
public Opt<T> ThrowIfNone<E>(
	Func<E> getException
)
where E : Exception

Parameters

getException  FuncE
Method to be called to create the exception if the option is of None variant.

Type Parameters

E

[Missing <typeparam name="E"/> documentation for "M:Orx.Fun.Option.Opt`1.ThrowIfNone``1(System.Func{``0})"]

Return Value

OptT

See Also