/// <summary> /// Uses the message of the given operation result if it doesn't match as a success to execute the <c>use</c> side effect. /// The source operation result is passed on unchanged. /// </summary> /// <param name="source">The operation result to be processed.</param> /// <param name="use">The side effect to be executed for the source result error message if it matches as an error or for the exception message if it matches as a failure.</param> /// <param name="getFailureMessage">A function used to extract the exception message from the result if it matches as a failure.</param> /// <typeparam name="T">The expected type of the source result value.</typeparam> /// <returns>The source operation result.</returns> public static IOperationResult <T> UseError <T>(this IOperationResult <T> source, Action <string> use, Func <Exception, string> getFailureMessage) { return(source.UseError((_, error) => use(error), getFailureMessage)); }