public static bool ReportAndCatchUnlessCanceled(Exception exception, CancellationToken contextCancellationToken, ErrorSeverity severity = ErrorSeverity.Uncategorized) { if (ExceptionUtilities.IsCurrentOperationBeingCancelled(exception, contextCancellationToken) || exception is OperationCanceledIgnoringCallerTokenException) { return(false); } return(ReportAndCatch(exception, severity)); }
public static bool ReportAndPropagateUnlessCanceled(Exception exception, CancellationToken contextCancellationToken, ErrorSeverity severity = ErrorSeverity.Uncategorized) { if (ExceptionUtilities.IsCurrentOperationBeingCancelled(exception, contextCancellationToken)) { return(false); } return(ReportAndPropagate(exception, severity)); }
internal static Action <TInput1, TInput2, CancellationToken> WrapUserAction <TInput1, TInput2>(this Action <TInput1, TInput2> userAction) { return((input1, input2, token) => { try { userAction(input1, input2); } catch (Exception e) when(!ExceptionUtilities.IsCurrentOperationBeingCancelled(e, token)) { throw new UserFunctionException(e); } }); }
internal static Func <TInput, CancellationToken, TOutput> WrapUserFunction <TInput, TOutput>(this Func <TInput, CancellationToken, TOutput> userFunction) { return((input, token) => { try { return userFunction(input, token); } catch (Exception e) when(!ExceptionUtilities.IsCurrentOperationBeingCancelled(e, token)) { throw new UserFunctionException(e); } }); }
public static bool ReportIfNonFatalAndCatchUnlessCanceled(Exception exception, CancellationToken contextCancellationToken, ErrorSeverity severity = ErrorSeverity.Uncategorized) { if (ExceptionUtilities.IsCurrentOperationBeingCancelled(exception, contextCancellationToken)) { return(false); } if (!HandlerIsNonFatal) { // We'll catch the exception, but we won't report anything. return(true); } return(ReportAndCatch(exception, severity)); }