Exemplo n.º 1
0
        public static ContinuationExpression OnException(this IHasErrorHandlers handlers, Type type)
        {
            if (!type.CanBeCastTo <Exception>())
            {
                throw new InvalidOperationException($"{type.FullName} is not an Exception type");
            }

            return(typeof(OnExceptionExpression <>).CloseAndBuildAs <ContinuationExpression>(handlers, type));
        }
Exemplo n.º 2
0
            public OnExceptionExpression(IHasErrorHandlers parent, Func <T, bool> filter)
            {
                _handler = new Lazy <ErrorHandler>(() =>
                {
                    var handler = new ErrorHandler();
                    handler.AddCondition(new ExceptionTypeMatch <T>(filter));
                    parent.ErrorHandlers.Add(handler);

                    return(handler);
                });
            }
Exemplo n.º 3
0
        internal static IContinuation DetermineContinuation(this IHasErrorHandlers errorHandling, Envelope envelope, Exception ex)
        {
            foreach (var handler in errorHandling.ErrorHandlers)
            {
                var continuation = handler.DetermineContinuation(envelope, ex);
                if (continuation != null)
                {
                    return(continuation);
                }
            }

            return(null);
        }
Exemplo n.º 4
0
 public OnExceptionExpression(IHasErrorHandlers parent) : this(parent, e => true)
 {
 }
Exemplo n.º 5
0
 public static ContinuationExpression OnException <T>(this IHasErrorHandlers handlers, Func <T, bool> filter = null) where T : Exception
 {
     return(new OnExceptionExpression <T>(handlers, filter));
 }
Exemplo n.º 6
0
 public static void HandleErrorsWith(this IHasErrorHandlers errorHandling, IErrorHandler errorHandler)
 {
     errorHandling.ErrorHandlers.Add(errorHandler);
 }
Exemplo n.º 7
0
 public static void HandleErrorsWith <T>(this IHasErrorHandlers errorHandling) where T : IErrorHandler, new()
 {
     errorHandling.HandleErrorsWith(new T());
 }
Exemplo n.º 8
0
 public override void SetUp()
 {
     _errorHandling = Context.State.Retrieve <IHasErrorHandlers>();
     _errorHandling.ErrorHandlers.Clear();
 }
Exemplo n.º 9
0
 public static ContinuationExpression OnException <T>(this IHasErrorHandlers handlers) where T : Exception
 {
     return(new OnExceptionExpression <T>(handlers));
 }