/// <summary> /// Adds the given <paramref name="exceptionHandler"/> for exceptions assignable to type /// <typeparamref name="TException"/> to this Try's call sequence. /// </summary> public AsyncTry <T> CatchAsync <TException>(Func <TException, Task <T> > exceptionHandler) where TException : Exception { TryThrowHelper.VerifyExceptionHandlerNotNull(exceptionHandler); var clause = new AsyncCatchClause( async ex => await exceptionHandler((TException)ex).ConfigureAwait(false), typeof(TException)); return(new AsyncTry <T>(Frames.Add(new AsyncTryFrame(TryFrameType.CatchClause, null, clause)))); }
/// <summary> /// Adds the given <paramref name="exceptionHandler"/> for exceptions assignable to type /// <paramref name="exceptionType"/> to this Try's call sequence. /// </summary> public AsyncTry <T> CatchAsync(Type exceptionType, Func <Exception, Task <T> > exceptionHandler) { TryThrowHelper.VerifyExceptionType(exceptionType); TryThrowHelper.VerifyExceptionHandlerNotNull(exceptionHandler); var clause = new AsyncCatchClause( async ex => await exceptionHandler(ex).ConfigureAwait(false), exceptionType); return(new AsyncTry <T>(Frames.Add(new AsyncTryFrame(TryFrameType.CatchClause, null, clause)))); }
/// <summary> /// Adds the given <paramref name="exceptionHandler"/> for exceptions assignable to type /// <paramref name="exceptionType"/> to this Try's call sequence. /// </summary> public AsyncTry <T> Catch(Type exceptionType, Func <Exception, T> exceptionHandler) { TryThrowHelper.VerifyExceptionType(exceptionType); TryThrowHelper.VerifyExceptionHandlerNotNull(exceptionHandler); var clause = new AsyncCatchClause( async ex => exceptionHandler(ex), exceptionType); return(new AsyncTry <T>(Frames.Add(new AsyncTryFrame(TryFrameType.CatchClause, null, clause)))); }