Esempio n. 1
0
        /// <summary>
        /// Formats and translates the exception into an <see cref="IExceptionEntry"/> object.
        /// </summary>
        /// <param name="exception">The exception to format.</param>
        /// <param name="entry">The <see cref="IExceptionEntry"/> object to format.</param>
        /// <returns>The entry object provided with excpetion information added.</returns>
        protected internal virtual IExceptionEntry FormatException(Exception exception, IExceptionEntry entry)
        {
            if (exception.InnerException != null)
            {
                entry.AddInnerExceptionMessage(exception.InnerException.ToString());

                var builder = new StringBuilder();

                var innerException = exception.InnerException;
                builder.AppendLine("----Flattened Exception Data[BEGIN]----");
                while (innerException != null)
                {
                    foreach (var pair in innerException.Data.Cast <DictionaryEntry>())
                    {
                        builder.Append(pair.Key).Append(":").Append(pair.Value).AppendLine("---");
                    }

                    innerException = innerException.InnerException;
                }
                builder.AppendLine("----Flattened Exception Data[END]----");

                entry.AddInnerExceptionMessage(builder.ToString());
            }

            entry.AddMessage(exception.Message);

            entry.Source = exception.Source;

            entry.Type = exception.GetType().Name;

            entry.StackTrace = exception.StackTrace;

            entry.TargetSite = exception.TargetSite == null ? string.Empty : exception.TargetSite.Name;

            if (exception.Data.Count > 0)
            {
                entry.AddMessage("---Main Exception Data---");
                try
                {
                    foreach (var pair in exception.Data.Cast <DictionaryEntry>())
                    {
                        entry.AddMessage(pair.Key + ": " + pair.Value);
                    }
                }
                catch { }
            }

            return(entry);
        }
Esempio n. 2
0
        public override IExceptionEntry FormatException(IExceptionEntry exceptionEntry)
        {
            exceptionEntry.AddMessage("This extensibility point is really useful!");

            return(base.FormatException(exceptionEntry));
        }