Exemplo n.º 1
0
        /// <summary>Initializes a new instance of the <see cref="ExceptionData"/> class.</summary>
        /// <param name="exception">The exception.</param>
        public ExceptionData(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException("exception");
            }

            this.exceptionType = exception.GetType().FullName;

            foreach (var k in exception.Data.Keys)
            {
                try
                {
                    var value = exception.Data[k];
                    var key   = k as string ?? k.ToString();
                    Add(key, value);
                }
                catch (Exception e)
                {
                    Console.WriteLine("ERROR: " + e);
                }
            }

            if (exception.InnerException == null)
            {
                return;
            }

            var exceptionData = new ExceptionData(exception.InnerException);

            exceptionData.AddTo(this);
        }
        /// <summary>Initializes a new instance of the <see cref="ExceptionData"/> class.</summary>
        /// <param name="exception">The exception.</param>
        public ExceptionData(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException("exception");
            }

            this.exceptionType = exception.GetType().FullName;

            foreach (var k in exception.Data.Keys)
            {
                try
                {
                    var value = exception.Data[k];
                    var key   = k as string ?? k.ToString();
                    Add(key, value);
                }
                catch (Exception e)
                {
                    SystemUtil.WriteError(e);
                }
            }

            if (exception.InnerException == null)
            {
                return;
            }

            var exceptionData = new ExceptionData(exception.InnerException);

            if (exceptionData.Count == 0)
            {
                return;
            }

            exceptionData.AddTo(this);
        }