Пример #1
0
        private void Compare(Exception ex, InnerError err, int level = 1)
        {
            Console.WriteLine("Level " + level);
            Assert.Equal(ex.GetType().FullName, err.Type);
            if (String.IsNullOrEmpty(ex.StackTrace))
            {
                Assert.Equal(0, err.StackTrace.Count);
            }
            else
            {
                string[] lines = Regex.Split(ex.StackTrace, "\r\n|\r|\n");
                Assert.Equal(lines.Length, err.StackTrace.Count);
                Assert.Equal(ex.StackTrace, err.StackTrace.ToString());
            }

            // TODO: Fix formatting bugs with inner exception tostring
            if (level == 1)
            {
                Assert.Equal(ex.ToString(), err.ToString());
            }

            if (ex.InnerException != null)
            {
                Compare(ex.InnerException, err.Inner, level + 1);
            }
        }
Пример #2
0
 public ApiError(InnerError?error)
 {
     Code    = error?.ToString() ?? "0";
     Message = OuterErrorMessageHelper.Get(error);
 }
Пример #3
0
        public bool IsDuplicate(Event ev)
        {
            if (!ev.IsError)
            {
                return(false);
            }

            InnerError current      = ev.GetError();
            DateTime   repeatWindow = DateTime.Now.AddSeconds(-2);

            while (current != null)
            {
                int hashCode = current.GetHashCode();
                _log.FormattedTrace(typeof(ExceptionlessClient), "Checking for duplicate error: hash={0} type={1}", hashCode, current.Type);
                _log.FormattedTrace(typeof(ExceptionlessClient), "Error contents: {0}", current.ToString());

                // make sure that we don't process the same error multiple times within 2 seconds.
                if (_recentlyProcessedErrors.Any(s => s.Item1 == hashCode && s.Item2 >= repeatWindow))
                {
                    _log.FormattedInfo(typeof(ExceptionlessClient), "Ignoring duplicate exception: type={0}", current.Type);
                    return(true);
                }

                // add this exception to our list of recent errors that we have processed.
                _recentlyProcessedErrors.Enqueue(Tuple.Create(hashCode, DateTime.Now));

                // only keep the last 10 recent errors
                Tuple <int, DateTime> temp;
                while (_recentlyProcessedErrors.Count > 10)
                {
                    _recentlyProcessedErrors.TryDequeue(out temp);
                }

                current = current.Inner;
            }

            return(false);
        }