api/PayrollProcessor.Core.Domain/Intrastructure/LanguageExtensions/TryAsyncLanguageExtensions.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 TryAsync<T> DoIfFail<T>(this TryAsync<T> t, Action<Exception> ifFail) => async () =>
          {
              var optionResult = await t.Try();
              if (optionResult.IsFaulted)
              {
                  optionResult.IfFail(ifFail);
              }
              return optionResult;
          };
public static TryAsync < T > DoIfFail < T > ( this TryAsync < 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
TryAsync<T>
this
ifFail
Action<Exception>
Action to execute with the exception that caused the failure
Action to execute with the exception that caused the failure
t
None
typeparam
None