/// <summary> /// Uses the message of the given operation result if it doesn't match as a success to execute the asynchronous <c>useAsync</c> side effect. /// The source operation result is passed on as a task result. /// </summary> /// <param name="source">The operation result to be processed.</param> /// <param name="useAsync">The asynchronous 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>A task returning the source operation result.</returns> public static async Task <IOperationResult <T> > UseErrorAsync <T>(this IOperationResult <T> source, Func <string, Task> useAsync, Func <Exception, string> getFailureMessage) { return(await source.UseErrorAsync(async (_, error) => await useAsync(error), getFailureMessage)); }