ResTryMapTOut Method

Returns the error when IsErr. Otherwise, tries to map into Ok(map()) in a try-catch block and returns the Err if it throws.
C#
static Res ValidateUser(User user) { /*returns Ok if valid; Err o/w*/ }
static Res<Secret> TryGetSecrets(User user) { /*returns Ok(secrets) if succeds; Err if fails to get secrets*/ }

User user = GetUser(..);
var secrets = ValidateUser(user).TryMap(() => TryGetSecrets(user));
// TryGetSecrets will be called only if ValidateUser call returns Ok;
// secrets will be Ok of the grabbed secrets if both ValidateUser and TryGetSecrets return Ok.

Definition

Namespace: Orx.Fun.Result
Assembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
C#
public Res<TOut> TryMap<TOut>(
	Func<TOut> map,
	string name = ""
)

Parameters

map  FuncTOut
Map function to be called lazily to create the result only if this IsOk.
name  String  (Optional)
Name of the map function; to be appended to the error messages if the function throws. Omitting the argument will automatically be filled with the function's expression in the caller side.

Type Parameters

TOut

[Missing <typeparam name="TOut"/> documentation for "M:Orx.Fun.Result.Res.TryMap``1(System.Func{``0},System.String)"]

Return Value

ResTOut

See Also