Ejemplo n.º 1
0
        /// <summary>
        /// Prints the contents of <paramref name="this"/> to the given <see cref="TextWriter"/>.
        /// </summary>
        /// <param name="this">The <see cref="Exception"/> to print.</param>
        /// <param name="writer">The <see cref="TextWriter"/> to write exception information to.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if either <paramref name="this"/> or <paramref name="writer"/> is <c>null</c>.
        /// </exception>
        public static void Print(this Exception @this, TextWriter writer)
        {
            @this.CheckParameterForNull("@this");
            writer.CheckParameterForNull("writer");

            writer.WriteLine("Type Name: {0}", @this.GetType().FullName);

            writer.WriteLine("\tSource: {0}", @this.Source);
            writer.WriteLine("\tTargetSite: {0}", ExceptionExtensions.FormatMethod(@this.TargetSite));
            writer.WriteLine("\tMessage: {0}", @this.Message);
            writer.WriteLine("\tHelpLink: {0}", @this.HelpLink);

            @this.PrintCustomProperties(writer);
            @this.PrintStackTrace(writer);
            @this.PrintData(writer);

            if (@this.InnerException != null)
            {
                writer.WriteLine();
                @this.InnerException.Print(writer);
            }
        }