ResTry Method
When IsOk executes
action() in a try-catch block: returns back itself if the process succeeds; Err if it throws.
Does not do anything and returns back itself when IsErr.
static Res TryLogin() { .. }
static void ClearSessionHistory() { /*risky function, might throw!*/ }
var result = TryLogin().Try(ClearSessionHistory);
// the result will be:
// - Err if TryLogin returns Err, in which case ClearSessionHistory is never called;
// - Ok if TryLogin returns Ok; and ClearSessionHistory call succeeds without an exception;
// - Err if TryLogin returns Ok, but ClearSessionHistory throws an exception.
Namespace: Orx.Fun.ResultAssembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
public Res Try(
Action action,
string name = ""
)
- action Action
- Action to be executed in a try-catcy block only if this IsOk.
- name String (Optional)
- Name of the map action; to be appended to the error messages if the action throws. Omitting the argument will automatically be filled with the action's expression in the caller side.
Res