Exemple #1
0
        public static void AddEntry(
            LogEditor logEditor,
            UnhandledExceptionEventArgs e)
        {
            if (e == null)
            {
                logEditor?.AddEntry(
                    ErrorType,
                    new[]
                {
                    @"An unhandled exception occurred, "
                    + @"but the event args object was null."
                });
                return;
            }

            var eo = e.ExceptionObject;

            if (eo == null)
            {
                logEditor?.AddEntry(
                    ErrorType,
                    new[]
                {
                    @"An unhandled exception occurred, "
                    + @"but the exception object was null."
                });
                return;
            }

            var ex = eo as Exception;

            if (ex == null)
            {
                logEditor?.AddEntry(
                    ErrorType,
                    new[]
                {
                    @"An unhandled exception occurred, but the exception "
                    + @"did not derive from System.Exception.",
                    @"Here is the exception's type: "
                    + eo.GetType()
                });
                return;
            }

            AddEntry(logEditor, ex);
        }
Exemple #2
0
        public static void AddEntry(
            LogEditor logEditor,
            Exception e)
        {
            var content = new List <string>
            {
                e.GetType().ToString(),
                e.Message,
                string.Empty,
                StackTraceHeader,
            };

            content.AddRange(ExceptionHelpers
                             .TrimmedStackTraceFor(e));

            var ie = e.InnerException;

            if (ie != null)
            {
                content.Add(string.Empty);
                content.Add(string.Empty);
                content.Add(@"Inner exception: " + ie.GetType());
                content.Add(ie.Message);
                content.Add(string.Empty);
                content.Add(StackTraceHeader);
                content.AddRange(ExceptionHelpers
                                 .TrimmedStackTraceFor(ie));
            }

            logEditor?.AddEntry(
                ErrorType,
                content.ToArray());
        }
Exemple #3
0
        void LogEditor.AddEntry(
            string type,
            IEnumerable <string> content)
        {
            LogEditor editor = this;

            editor.AddEntry(
                new LogEntry(
                    type,
                    new LinkedListLot <string>(content)));
        }