Пример #1
0
 public ExceptionHandler GetHandler(ExceptionHandlerFactoryContext context)
 {
     FactoryContexts.Add(context);
     var handler = new SupportExceptionHandler();
     Handlers.Add(handler);
     return handler.Handle;
 }
        protected static ExceptionHandlingService InitExceptionHandling(
            string runtimeURI,
            ConfigurationRuntimeExceptionHandling exceptionHandling,
            ConfigurationRuntimeConditionHandling conditionHandling,
            ClassForNameProvider classForNameProvider)
        {
            IList<ExceptionHandler> exceptionHandlers;
            if (exceptionHandling.HandlerFactories == null || exceptionHandling.HandlerFactories.IsEmpty()) {
                exceptionHandlers = new EmptyList<ExceptionHandler>();
            }
            else {
                exceptionHandlers = new List<ExceptionHandler>();
                var context = new ExceptionHandlerFactoryContext(runtimeURI);
                foreach (var className in exceptionHandling.HandlerFactories) {
                    try {
                        var factory = TypeHelper.Instantiate<ExceptionHandlerFactory>(
                            className, classForNameProvider);
                        var handler = factory.GetHandler(context);
                        if (handler == null) {
                            Log.Warn("Exception handler factory '" + className + "' returned a null handler, skipping factory");
                            continue;
                        }

                        exceptionHandlers.Add(handler);
                    }
                    catch (Exception ex) {
                        throw new ConfigurationException(
                            "Exception initializing exception handler from exception handler factory '" + className + "': " + ex.Message, ex);
                    }
                }
            }

            IList<ConditionHandler> conditionHandlers;
            if (conditionHandling.HandlerFactories == null || conditionHandling.HandlerFactories.IsEmpty()) {
                conditionHandlers = new EmptyList<ConditionHandler>();
            }
            else {
                conditionHandlers = new List<ConditionHandler>();
                var context = new ConditionHandlerFactoryContext(runtimeURI);
                foreach (var className in conditionHandling.HandlerFactories) {
                    try {
                        var factory = TypeHelper.Instantiate<ConditionHandlerFactory>(
                            className, classForNameProvider);
                        var handler = factory.GetHandler(context);
                        if (handler == null) {
                            Log.Warn("Condition handler factory '" + className + "' returned a null handler, skipping factory");
                            continue;
                        }

                        conditionHandlers.Add(handler);
                    }
                    catch (Exception ex) {
                        throw new ConfigurationException(
                            "Exception initializing exception handler from exception handler factory '" + className + "': " + ex.Message, ex);
                    }
                }
            }

            return new ExceptionHandlingService(runtimeURI, exceptionHandlers, conditionHandlers);
        }
Пример #3
0
        public ExceptionHandler GetHandler(ExceptionHandlerFactoryContext context)
        {
            factoryContexts.Add(context);

            SupportExceptionHandler handler = new SupportExceptionHandler();

            handlers.Add(handler);
            return(handler.Handle);
        }
 public ExceptionHandler GetHandler(ExceptionHandlerFactoryContext context)
 {
     return(Handle);
 }
Пример #5
0
        internal static ExceptionHandlingService InitExceptionHandling(
            String engineURI,
            ConfigurationEngineDefaults.ExceptionHandling exceptionHandling,
            ConfigurationEngineDefaults.ConditionHandling conditionHandling)
        {
            List <ExceptionHandler> exceptionHandlers;

            if (exceptionHandling.HandlerFactories == null || exceptionHandling.HandlerFactories.IsEmpty())
            {
                exceptionHandlers = new List <ExceptionHandler>();
            }
            else
            {
                exceptionHandlers = new List <ExceptionHandler>();
                var context = new ExceptionHandlerFactoryContext(engineURI);
                foreach (String className in exceptionHandling.HandlerFactories)
                {
                    try {
                        var factory = TypeHelper.Instantiate <ExceptionHandlerFactory>(className);
                        var handler = factory.GetHandler(context);
                        if (handler == null)
                        {
                            Log.Warn("Exception handler factory '" + className + "' returned a null handler, skipping factory");
                            continue;
                        }
                        exceptionHandlers.Add(handler);
                    }
                    catch (Exception ex) {
                        throw new ConfigurationException("Exception initializing exception handler from exception handler factory '" + className + "': " + ex.Message, ex);
                    }
                }
            }

            List <ConditionHandler> conditionHandlers;

            if (conditionHandling.HandlerFactories == null || conditionHandling.HandlerFactories.IsEmpty())
            {
                conditionHandlers = new List <ConditionHandler>();
            }
            else
            {
                conditionHandlers = new List <ConditionHandler>();
                var context = new ConditionHandlerFactoryContext(engineURI);
                foreach (String className in conditionHandling.HandlerFactories)
                {
                    try {
                        var factory = TypeHelper.Instantiate <ConditionHandlerFactory>(className);
                        var handler = factory.GetHandler(context);
                        if (handler == null)
                        {
                            Log.Warn("Condition handler factory '" + className + "' returned a null handler, skipping factory");
                            continue;
                        }
                        conditionHandlers.Add(handler);
                    }
                    catch (Exception ex) {
                        throw new ConfigurationException("Exception initializing exception handler from exception handler factory '" + className + "': " + ex.Message, ex);
                    }
                }
            }

            return(new ExceptionHandlingService(engineURI, exceptionHandlers, conditionHandlers));
        }
 public ExceptionHandler GetHandler(ExceptionHandlerFactoryContext context)
 {
     return new SupportExceptionHandlerRethrow().Handle;
 }