Пример #1
0
 private void FilterStackFrames(ExceptionEntity exceptionDefinition, StackFrameFilterDefinition filterDefinition)
 {
     switch (filterDefinition.FilterType)
     {
         case StackFrameFilterType.NotHigherThanApplicationCode:
             FilterStackFramesHigherThanAppCode(exceptionDefinition);
             break;
         case StackFrameFilterType.NotLowerThanApplicationCode:
             FilterStackFramesLowerThanAppCode(exceptionDefinition);
             break;
         case StackFrameFilterType.RegexPattern:
             ApplyRegexFilter(exceptionDefinition, filterDefinition);
             break;
         default:
             throw new Exception("Unsupported StackFrameFilterType");
     }
 }
Пример #2
0
        private void NonExceptionError(short depth)
        {
            var exception = new ExceptionEntity();
            _exceptions.Add(exception);
            exception.Depth = depth;
            exception.ExceptionType = "NONE";
            exception.Message = ReadToken(TokenType.Text).Value;
            DiscardToken(TokenType.Text);

            if(_lookaheadFirst.TokenType == TokenType.StackFrame)
                StackFrame(exception, 1);
        }
Пример #3
0
        private void RethrownAtStackFrame(ExceptionEntity exception, short depth)
        {
            var stackFrame = new StackFrameEntity()
            {
                Depth = depth,
                IsApplicationCode = false,
                Path = "Rethrown"
            };

            exception.StackFrames.Add(stackFrame);
        }
Пример #4
0
        private short StackFrame(ExceptionEntity exception, short depth)
        {
            var stackFrameText = GetStackFrameFromToken(ReadToken(TokenType.StackFrame).Value);
            var stackFrame = new StackFrameEntity()
            {
                Depth = depth,
                IsApplicationCode = IsApplicationStackFrame(stackFrameText),
                Path = stackFrameText
            };
            
            exception.StackFrames.Add(stackFrame);
            DiscardToken(TokenType.StackFrame);

            if (_lookaheadFirst.TokenType == TokenType.StackFrame)
            {
                var newDepth = (short)(depth + 1);
                return StackFrame(exception, newDepth);
            }

            return depth;
        }
Пример #5
0
        private void AggregateException()
        {
            var exception = new ExceptionEntity();
            _exceptions.Add(exception);
            exception.Depth = 1;
            exception.ExceptionType = GetExceptionType(ReadToken(TokenType.AggregateException).Value);
            DiscardToken(TokenType.AggregateException);
            exception.Message = ReadToken(TokenType.Text).Value;
            DiscardToken(TokenType.Text);

            InnerException(2);
            InnerAggregateException();
        }
Пример #6
0
        private void FaultExceptionWithoutDetail(short depth)
        {
            var exception = new ExceptionEntity();
            _exceptions.Add(exception);
            exception.Depth = depth;
            exception.ExceptionType = "System.ServiceModel.FaultException";
            DiscardToken(TokenType.FaultExceptionWithoutDetail);
            exception.Message = ReadToken(TokenType.Text).Value;
            DiscardToken(TokenType.Text);

            if (_lookaheadFirst.TokenType == TokenType.ServerStackTraceMarker)
            {
                ServerStackTrace(exception);
            }
            else
            {
                throw new ErrorParserException(string.Format("Expected a server stack trace marker but found {0} with value {1}",
                        _lookaheadFirst.TokenType, _lookaheadFirst.Value));
            }
        }
Пример #7
0
 private void ServerStackTrace(ExceptionEntity exception)
 {
     DiscardToken(TokenType.ServerStackTraceMarker);
     var deepestStackFrame = StackFrame(exception, 1);
     DiscardToken(TokenType.RethrownAtMarker);
     RethrownAtStackFrame(exception, (short) (deepestStackFrame + 1));
     StackFrame(exception, (short)(deepestStackFrame + 2));
 }
Пример #8
0
        private void Exception(short depth)
        {
            var exception = new ExceptionEntity();
            _exceptions.Add(exception);
            exception.Depth = depth;
            exception.ExceptionType = GetExceptionType(ReadToken(TokenType.Exception).Value);
            DiscardToken(TokenType.Exception);
            exception.Message = ReadToken(TokenType.Text).Value;
            DiscardToken(TokenType.Text);

            if (_lookaheadFirst.TokenType == TokenType.StackFrame)
            {
                StackFrame(exception, 1);
            }
            else if (_lookaheadFirst.TokenType == TokenType.StartInnerExceptionMarker)
            {
                InnerException((short)(depth + 1));
                if (_lookaheadFirst.TokenType == TokenType.StackFrame)
                {
                    StackFrame(exception, 1);
                }
                else if (_lookaheadFirst.TokenType == TokenType.ServerStackTraceMarker)
                {
                    ServerStackTrace(exception);
                }
            }
            else
                throw new ErrorParserException(string.Format("Expected a stack frame or inner exception marker but found {0} with value {1}", _lookaheadFirst.TokenType, _lookaheadFirst.Value));
        }
Пример #9
0
 private void FilterStackFramesLowerThanAppCode(ExceptionEntity exceptionDefinition)
 {
     exceptionDefinition.StackFrames = CutOffLowerThanAppCode(exceptionDefinition.StackFrames).ToList();
 }
Пример #10
0
 private void FilterStackFrames(ExceptionEntity exceptionDefinition)
 {
     foreach (var filterDef in _stackFrameFilterGroup.Definitions)
         FilterStackFrames(exceptionDefinition, filterDef);
 }
Пример #11
0
        private void ApplyRegexFilter(ExceptionEntity exceptionDefinition, StackFrameFilterDefinition filterDefinition)
        {
            var stackFrameRegex = new Regex(filterDefinition.RegexFilterPattern);

            var filteredStackFrames = new List<StackFrameEntity>();
            foreach (var stackFrame in exceptionDefinition.StackFrames)
            {
                if(!stackFrameRegex.IsMatch(stackFrame.Path))
                    filteredStackFrames.Add(stackFrame);
            }

            exceptionDefinition.StackFrames = filteredStackFrames;
        }
Пример #12
0
        private void ReDepthIndexStackFrames(ExceptionEntity exceptionDefinition)
        {
            int count = exceptionDefinition.StackFrames.Count;
            short minDepth = exceptionDefinition.StackFrames.Min(x => x.Depth);
            short diff = (short)(minDepth - 1);

            for (int i = 0; i < count; i++)
                exceptionDefinition.StackFrames[i].Depth = (short)(exceptionDefinition.StackFrames[i].Depth - diff);
        }
Пример #13
0
        public ExceptionEntity GetException(ExceptionBlock exceptionBlock)
        {
            var exceptionTypeInfo = GetExceptionType(exceptionBlock);

            var exception = new ExceptionEntity();
            exception.Depth = (short)exceptionBlock.Depth;
            exception.ExceptionType = exceptionTypeInfo.Item3;
            exception.Message = GetExceptionMessage(exceptionBlock.Text, exceptionTypeInfo.Item1, exceptionTypeInfo.Item2);
            
            var stackFrames = ExtractStackFrames(exceptionBlock.Text);
            if (exceptionBlock.ParserMode == ParserMode.FaultException)
                stackFrames = FilterUnstableStackFrames(stackFrames);

            exception.StackFrames = stackFrames;

            return exception;
        }