Пример #1
0
        Exception IExceptionManager.Handle(Exception exception, out PostHandleAction action)
        {
            action = PostHandleAction.None;
            var returnVal         = exception;
            var exceptionFullName = exception.GetType().FullName;

            SortedExceptionConfigList <ExceptionHandlerConfig, IExceptionHandler> handlers;

            if (this.exceptionPolicy.HandlerMap.TryGetValue(exceptionFullName, out handlers))
            {
                foreach (var handler in handlers)
                {
                    bool handled;
                    var  handlerException = handler.Value.Value.Handle(exception, out handled);
                    if (handled)
                    {
                        action    = handler.Value.Key.HandlerAction;
                        returnVal = handlerException;
                        break;
                    }
                }
            }

            if (action == PostHandleAction.None && this.exceptionPolicy.HandlerMap.TryGetValue(typeof(Exception).FullName, out handlers))
            {
                foreach (var handler in handlers)
                {
                    bool handled;
                    var  handlerException = handler.Value.Value.Handle(exception, out handled);
                    if (handled)
                    {
                        action    = handler.Value.Key.HandlerAction;
                        returnVal = handlerException;
                        break;
                    }
                }
            }

            return(returnVal);
        }
Пример #2
0
        Exception IExceptionManager.Handle(Exception exception, out PostHandleAction action)
        {
            action = PostHandleAction.None;
            var returnVal = exception;
            var exceptionFullName = exception.GetType().FullName;

            SortedExceptionConfigList<ExceptionHandlerConfig, IExceptionHandler> handlers;
            if (this.exceptionPolicy.HandlerMap.TryGetValue(exceptionFullName, out handlers))
            {
                foreach (var handler in handlers)
                {
                    bool handled;
                    var handlerException = handler.Value.Value.Handle(exception, out handled);
                    if (handled)
                    {
                        action = handler.Value.Key.HandlerAction;
                        returnVal = handlerException;
                        break;
                    }
                }
            }

            if (action == PostHandleAction.None && this.exceptionPolicy.HandlerMap.TryGetValue(typeof(Exception).FullName, out handlers))
            {
                foreach (var handler in handlers)
                {
                    bool handled;
                    var handlerException = handler.Value.Value.Handle(exception, out handled);
                    if (handled)
                    {
                        action = handler.Value.Key.HandlerAction;
                        returnVal = handlerException;
                        break;
                    }
                }
            }

            return returnVal;
        }