Method ValueOrException
ValueOrException<T>(Maybe<T>, Exception)
Returns the value of source if it is not empty, otherwise throws the provided exception.
Declaration
public static T ValueOrException<T>(this Maybe<T> source, Exception exception)
Parameters
| Type | Name | Description |
|---|---|---|
| Maybe<T> | source | The Mabye{T} instance whose value is returned if it is not empty. |
| Exception | exception | The exception to throw if |
Returns
| Type | Description |
|---|---|
| T | The value of |
Type Parameters
| Name | Description |
|---|---|
| T | The sub-type of the Maybe{T} instances. |
ValueOrException<T>(Maybe<T>, Func<Exception>)
Returns the value of source if it is not empty, otherwise throws an exception created from the function provided.
Declaration
public static T ValueOrException<T>(this Maybe<T> source, Func<Exception> exceptionFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| Maybe<T> | source | The Mabye{T} instance whose value is returned if it is not empty. |
| Func<Exception> | exceptionFactory | A function that builds the exception to be thrown if |
Returns
| Type | Description |
|---|---|
| T | The value of |
Type Parameters
| Name | Description |
|---|---|
| T | The sub-type of the Maybe{T} instances. |