api/PayrollProcessor.Core.Domain/Intrastructure/LanguageExtensions/TryOptionAsyncLanguageExtensions.cs
/// <summary>
/// Performs the given action if the operation results in a failed state
/// </summary>
/// <param name="t">Current operation</param>
/// <param name="ifFail">Action to execute with the exception that caused the failure</param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
Performs the given action if the operation results in a failed state
Performs the given action if the operation results in a failed state
public static TryOptionAsync<T> DoIfFail<T>(this TryOptionAsync<T> t, Action<Exception> ifFail) => async () =>
           {
               var optionResult = await t.Try();
               if (optionResult.IsFaulted)
               {
                   optionResult.IfFail(ifFail);
               }
               return optionResult;
           };
public static TryOptionAsync < T > DoIfFail < T > ( this TryOptionAsync < T > t , Action < Exception > ifFail ) => async ( ) => { var optionResult = await t . Try ( ) ; if ( optionResult . IsFaulted ) { optionResult . IfFail ( ifFail ) ; } return optionResult ; } ;
Performs the given action if the operation results in a failed state
Performs the given action if the operation results in a failed state
None
TryOptionAsync<T>
this
<not_specific>
ifFail
Action<Exception>
Action to execute with the exception that caused the failure
Action to execute with the exception that caused the failure
t
<not_specific>
None
typeparam
None