/// <summary> /// Appends a new exception catcher to the <see cref="TryCatch"/> block. /// </summary> /// <typeparam name="TException"></typeparam> /// <param name="tryCatch"></param> /// <param name="action"></param> /// <returns></returns> public static TryCatch Catch <TException>(this TryCatch tryCatch, Func <DelegateInArgument <TException>, Activity> action) where TException : Exception { if (tryCatch == null) { throw new ArgumentNullException(nameof(tryCatch)); } if (action == null) { throw new ArgumentNullException(nameof(action)); } return(tryCatch.Catch(Delegate(action))); }
/// <summary> /// Appends a new exception catcher to the <see cref="TryCatch"/> block. /// </summary> /// <typeparam name="TException"></typeparam> /// <param name="tryCatch"></param> /// <param name="action"></param> /// <returns></returns> public static TryCatch Catch <TException>(this TryCatch tryCatch, Func <TException, Task> action) where TException : Exception { if (tryCatch == null) { throw new ArgumentNullException(nameof(tryCatch)); } if (action == null) { throw new ArgumentNullException(nameof(action)); } return(tryCatch.Catch <TException>(arg => Invoke(action, arg))); }